﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using Infragistics.Win.UltraWinCalcManager;
using Infragistics.Win.CalcEngine;
using WHC.Security.Common;
namespace BYManageInfoSystem
{
    public partial class Frm_DataProcess : Form
    {
        private DGBY.BLL.T_ACL_User m_bllT_ACL_User = new DGBY.BLL.T_ACL_User();
        private DGBY.BLL.FeeHKYSTruePayTab m_bllFeeHKYSTruePayTab = new DGBY.BLL.FeeHKYSTruePayTab();
        private DGBY.BLL.FeeDZTruePayTab m_bllFeeDZTruePayTab = new DGBY.BLL.FeeDZTruePayTab();
        private DGBY.BLL.FinCheckInvoiceRecordDetailAuxiliaryTab_New m_bllInvoiceAuxiliary_New
    = new DGBY.BLL.FinCheckInvoiceRecordDetailAuxiliaryTab_New();
        private DGBY.BLL.FeeHKCWTruePayTab m_bllFeeHKCWTruePayTab = new DGBY.BLL.FeeHKCWTruePayTab();
        private DGBY.BLL.FeeBGTruePayTab m_bllFeeBGTruePayTab = new DGBY.BLL.FeeBGTruePayTab();
        private DGBY.BLL.FeeDLCWTruePayTab m_bllFeeDLCWTruePayTab = new DGBY.BLL.FeeDLCWTruePayTab();
        private DGBY.BLL.FeeDHLTruePayTab m_bllFeeDHLTruePayTab = new DGBY.BLL.FeeDHLTruePayTab();
        private DGBY.BLL.FeeZXZTruePayTab m_bllFeeZXZTruePayTab = new DGBY.BLL.FeeZXZTruePayTab();
        private DGBY.BLL.FeeJCFTruePayTab m_bllFeeJCFTruePayTab = new DGBY.BLL.FeeJCFTruePayTab();

        private DGBY.BLL.FeeSJTruePayTab m_bllFeeSJTruePayTab = new DGBY.BLL.FeeSJTruePayTab();
        private DGBY.BLL.BYCompBankCountTab m_bllBYCompBankCountTab = new DGBY.BLL.BYCompBankCountTab();

        private DGBY.BLL.PaidanRegisterDetailTab m_bllPaidanRegisterDetailTab = new DGBY.BLL.PaidanRegisterDetailTab();
        private DGBY.BLL.FacConPeoAndTelTab m_bllFacConPeoAndTelTab = new DGBY.BLL.FacConPeoAndTelTab();

        //private DGBY.BLL.BGPackingTab m_bllBGPackingTab = new DGBY.BLL.BGPackingTab();
        private DGBY.BLL.SJ_SJFeeTab m_bllSJ_SJFeeTab = new DGBY.BLL.SJ_SJFeeTab();
        private DGBY.BLL.TYInvoiceTab m_bllTYInvoiceTab = new DGBY.BLL.TYInvoiceTab();
        private DGBY.BLL.SJPackingTab m_bllSJPackingTab = new DGBY.BLL.SJPackingTab();
        private DGBY.BLL.FactoryGoodsTab m_bllFactoryGoodsTab = new DGBY.BLL.FactoryGoodsTab();
        private DGBY.BLL.FactoryDataTab m_bllFactoryDataTab = new DGBY.BLL.FactoryDataTab();
        Hashtable m_SQLStringList = new Hashtable();
        ArrayList m_arrayList = new ArrayList();
        private DGBY.BLL.BGCKHTTab m_bllBGCKHTTab = new DGBY.BLL.BGCKHTTab();
        private DGBY.BLL.BGPackingTab m_bllBGPackingTab = new DGBY.BLL.BGPackingTab();
        private DGBY.BLL.SJCKHTTab m_bllSJCKHTTab = new DGBY.BLL.SJCKHTTab();
        private DGBY.BLL.YSMethodTab m_bllYSMethodTab = new DGBY.BLL.YSMethodTab();

        private DGBY.BLL.HxdNoTab m_bllHxdNoTab = new DGBY.BLL.HxdNoTab();
        private DGBY.BLL.HxdNoTabTmp m_bllHxdNoTabTmp = new DGBY.BLL.HxdNoTabTmp();

        private DGBY.BLL.SJPackGoodsMXTab m_bllSJPackGoodsMXTab = new DGBY.BLL.SJPackGoodsMXTab();
        private DGBY.BLL.BGPackGoodsMXTab m_bllBGPackGoodsMXTab = new DGBY.BLL.BGPackGoodsMXTab();
       
        private DGBY.BLL.FinInvoiceRecordTab_New m_bllFinInvoiceRecordTab_New = new DGBY.BLL.FinInvoiceRecordTab_New();
        private DGBY.BLL.FinCheckInvoiceRecordDetailTab_New m_bllFinCheckInvoiceRecordDetailTab_New = new DGBY.BLL.FinCheckInvoiceRecordDetailTab_New();
        private DGBY.BLL.FinCheckInvoiceRecordDetailAuxiliaryTab_New m_bllFinCheckInvoiceRecordDetailAuxiliaryTab_New = new DGBY.BLL.FinCheckInvoiceRecordDetailAuxiliaryTab_New();
        private DGBY.BLL.FinRecvMoneyAuxiliaryTab_New m_bllFinRecvMoneyAuxiliaryTab_New = new DGBY.BLL.FinRecvMoneyAuxiliaryTab_New();
        private DGBY.BLL.FinRecvMoneyDetailTab_New m_bllFinRecvMoneyDetailTab_New = new DGBY.BLL.FinRecvMoneyDetailTab_New();
        private DGBY.BLL.FinDepRecvAndPayDetailTab_New m_bllFinDepRecvAndPayDetailTab_New = new DGBY.BLL.FinDepRecvAndPayDetailTab_New();
        private DGBY.BLL.PaidanRegisterTab m_bllPaidanRegisterTab = new DGBY.BLL.PaidanRegisterTab();

        public Frm_DataProcess()
        {
            InitializeComponent();
        }
        private void ProcessBGFee(int nPaidanRegisterTabID, string strContractNo)
        {
        
            int nFeeBGTruePayTabID = 0;
            DataSet ds = m_bllFeeBGTruePayTab.GetList("PaidanRegisterTab.PaidanRegisterTabID = '" + nPaidanRegisterTabID.ToString() + "'", "");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
               
                nFeeBGTruePayTabID = (int)ds.Tables[0].Rows[0]["FeeBGTruePayTabID"];
            }



            DataSet dsTemp = m_bllBGCKHTTab.ShowAllCKHTMX(strContractNo);
            int nItemCount = dsTemp.Tables[0].Rows.Count;
            DataSet dsInfo = m_bllBGCKHTTab.ShowContractInfo("PaidanRegisterTab.PaidanRegisterTabID = '" + nPaidanRegisterTabID.ToString() + "'");

            if (dsInfo.Tables.Count > 0 && dsInfo.Tables[0].Rows.Count > 0)
            {
                int nGuiCount = (int)dsInfo.Tables[0].Rows[0]["柜数"];
                if (nFeeBGTruePayTabID != 0)
                {
                    DGBY.Model.FeeBGTruePayTab modelFeeBGTruePayTabOld
   = m_bllFeeBGTruePayTab.GetModel(nFeeBGTruePayTabID);

                    modelFeeBGTruePayTabOld.BGFee = (Decimal)dsInfo.Tables[0].Rows[0]["应付报关费定价"];
                    modelFeeBGTruePayTabOld.GCFee = 0;
                    modelFeeBGTruePayTabOld.LGFee = ((Decimal)dsInfo.Tables[0].Rows[0]["应付连柜费定价"]) * (nGuiCount - 1);
                    modelFeeBGTruePayTabOld.TGDFee = (Decimal)dsInfo.Tables[0].Rows[0]["应付通关单费定价"];
                    modelFeeBGTruePayTabOld.GKJSFee = (Decimal)dsInfo.Tables[0].Rows[0]["应付港口建设费定价"] * nGuiCount;
                    modelFeeBGTruePayTabOld.CGFee = 0;
                    modelFeeBGTruePayTabOld.JYFee = ((Decimal)dsInfo.Tables[0].Rows[0]["应付加页费定价"]) * ((nItemCount - 1) / 5);
                    modelFeeBGTruePayTabOld.SMFee = 0;

                    modelFeeBGTruePayTabOld.BGBGFee = (Decimal)dsInfo.Tables[0].Rows[0]["应收报关费定价"];
                    modelFeeBGTruePayTabOld.BGGCFee = 0;
                    modelFeeBGTruePayTabOld.BGLGFee = ((Decimal)dsInfo.Tables[0].Rows[0]["应收连柜费定价"]) * (nGuiCount - 1);
                    modelFeeBGTruePayTabOld.BGTGDFee = (Decimal)dsInfo.Tables[0].Rows[0]["应收通关单费定价"];
                    modelFeeBGTruePayTabOld.BGGKJSFee = (Decimal)dsInfo.Tables[0].Rows[0]["应收港口建设费定价"] * nGuiCount;
                    modelFeeBGTruePayTabOld.BGCGFee = 0;
                    modelFeeBGTruePayTabOld.BGJYFee = ((Decimal)dsInfo.Tables[0].Rows[0]["应收加页费定价"]) * ((nItemCount - 1) / 5);
                    modelFeeBGTruePayTabOld.BGSMFee = 0;

                    modelFeeBGTruePayTabOld.IsSync = 1;
                    m_bllFeeBGTruePayTab.Update(modelFeeBGTruePayTabOld);
                }

            }
        }
        private void ProcessPaidanBGTruePay()
        {

            DataSet ds = m_bllFeeBGTruePayTab.GetList("CONVERT(varchar(6), HxdNoTab.SBDate, 112) = '201201'", "");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nPaidanRegisterTabID = (int)ds.Tables[0].Rows[i]["PaidanRegisterTabID"];
                    string strNo = ds.Tables[0].Rows[i]["合同编号"].ToString();
                    ProcessBGFee(nPaidanRegisterTabID, strNo);
                }
                //nFeeBGTruePayTabID = (int)ds.Tables[0].Rows[0]["FeeBGTruePayTabID"];
            }

            MessageBox.Show("ProcessPaidanBGTruePay还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

       
        }

        private void AddHxdNoTab(int nPaidanID)
        {

            //return;
            try
            {
                DGBY.Model.HxdNoTab modelHxdNoTabOld = new DGBY.Model.HxdNoTab();
                modelHxdNoTabOld.BGDNo = "";
                modelHxdNoTabOld.PaidanRegisterTabID = nPaidanID;
                modelHxdNoTabOld.HxdNo = 0;
                modelHxdNoTabOld.JCHxdDjTabID = 0;

                modelHxdNoTabOld.SBDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.LrHsBgdDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.SdHxdDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.YhxDate = DateTime.Parse("1900-01-01");

                modelHxdNoTabOld.JcwTszldDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.QtddjDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.Note = "";
                modelHxdNoTabOld.WeiTuoBook = "";

                modelHxdNoTabOld.CheckInvoiceDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.CKouDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.TongJDate = DateTime.Parse("1900-01-01");

                modelHxdNoTabOld.HsGHHTDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.HstddjDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.SCKHTdjDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.HZzsInvDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.JcGHHTDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.XbdzldjDate = DateTime.Parse("1900-01-01");

                modelHxdNoTabOld.HsbdzldjDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.ZlccdjDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.HsggzldjDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.TuiShuiZHDate = DateTime.Parse("1900-01-01");

                modelHxdNoTabOld.HSLLDDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.HSTYDDate = DateTime.Parse("1900-01-01");
                modelHxdNoTabOld.HSLCDDate = DateTime.Parse("1900-01-01");

                modelHxdNoTabOld.iswts = false;
                modelHxdNoTabOld.islld = false;
                modelHxdNoTabOld.istyd = false;
                modelHxdNoTabOld.isrcd = false;
                modelHxdNoTabOld.isfxt = false;
                modelHxdNoTabOld.istd = false;
                modelHxdNoTabOld.isckht = false;
                modelHxdNoTabOld.bitInvoiceWithContract = false;

                m_bllHxdNoTab.Add(modelHxdNoTabOld);
                MessageBox.Show("AddHxdNoTab还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
        private void ProcessPaidanRegisterDetailTab()
        {

            int nPaidanRegisterTabID = 0;
            DataSet dsTemp = m_bllPaidanRegisterTab.GetAllPaiDanList("PaidanRegisterTab.PaiDanDate >= '20120101'");

            if (dsTemp.Tables.Count > 0 && dsTemp.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < dsTemp.Tables[0].Rows.Count; i++)
                {
                    nPaidanRegisterTabID = (int)dsTemp.Tables[0].Rows[i]["PaidanRegisterTabID"];
                    DataSet ds = m_bllPaidanRegisterDetailTab.GetList("PaidanRegisterDetailTab.PaidanRegisterTabID = '" + nPaidanRegisterTabID + "'", false);

                    if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        continue;
                    }
                    DGBY.Model.PaidanRegisterDetailTab modelPaidanRegisterDetailTab
                        = new DGBY.Model.PaidanRegisterDetailTab();

                    modelPaidanRegisterDetailTab.PaidanRegisterTabID = nPaidanRegisterTabID;
                    modelPaidanRegisterDetailTab.GouHuoContractDate = DateTime.Parse("1900-01-01");
                    modelPaidanRegisterDetailTab.BusinessDate = DateTime.Parse("1900-01-01");
                    modelPaidanRegisterDetailTab.BackTaxDate = DateTime.Parse("1900-01-01");
                    modelPaidanRegisterDetailTab.Note = "";

                    m_bllPaidanRegisterDetailTab.Add(modelPaidanRegisterDetailTab);
                }

                MessageBox.Show("ProcessPaidanRegisterDetailTab还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }

        private void ProcessTenTruePay127()
        {
            DataSet ds = m_bllFeeHKYSTruePayTab.GetList(20,"PaidanRegisterTabID = 127", "PaidanRegisterTabID");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int FeeHKYSTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeHKYSTruePayTabID"];
                    m_bllFeeHKYSTruePayTab.Delete(FeeHKYSTruePayTabID);
                }
            }

            ds = m_bllFeeDZTruePayTab.GetList(20, "PaidanRegisterTabID = 127", "PaidanRegisterTabID");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int FeeDZTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeDZTruePayTabID"];
                    m_bllFeeDZTruePayTab.Delete(FeeDZTruePayTabID);
                }
            }


            ds = m_bllFeeSJTruePayTab.GetList(20, "PaidanRegisterTabID = 127", "PaidanRegisterTabID");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int FeeSJTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeSJTruePayTabID"];
                    m_bllFeeSJTruePayTab.Delete(FeeSJTruePayTabID);
                }
            }


            ds = m_bllFeeHKCWTruePayTab.GetList(20, "PaidanRegisterTabID = 127", "PaidanRegisterTabID");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int FeeHKCWTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeHKCWTruePayTabID"];
                    m_bllFeeHKCWTruePayTab.Delete(FeeHKCWTruePayTabID);
                }
            }

            ds = m_bllFeeBGTruePayTab.GetList(20, "PaidanRegisterTabID = 127", "PaidanRegisterTabID");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int FeeBGTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeBGTruePayTabID"];
                    m_bllFeeBGTruePayTab.Delete(FeeBGTruePayTabID);
                }
            }

            ds = m_bllFeeDLCWTruePayTab.GetList(20, "PaidanRegisterTabID = 127", "PaidanRegisterTabID");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int FeeDLCWTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeDLCWTruePayTabID"];
                    m_bllFeeDLCWTruePayTab.Delete(FeeDLCWTruePayTabID);
                }
            }

            ds = m_bllFeeDHLTruePayTab.GetList(20,"PaidanRegisterTabID = 127", "PaidanRegisterTabID");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int FeeDHLTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeDHLTruePayTabID"];
                    m_bllFeeDHLTruePayTab.Delete(FeeDHLTruePayTabID);
                }
            }

            ds = m_bllFeeZXZTruePayTab.GetList(20, "PaidanRegisterTabID = 127", "PaidanRegisterTabID");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int FeeZXZTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeZXZTruePayTabID"];
                    m_bllFeeZXZTruePayTab.Delete(FeeZXZTruePayTabID);
                }
            }
            ds = m_bllFeeJCFTruePayTab.GetList(20, "PaidanRegisterTabID = 127", "PaidanRegisterTabID");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int FeeJCFTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeJCFTruePayTabID"];
                    m_bllFeeJCFTruePayTab.Delete(FeeJCFTruePayTabID);
                }
            }



            MessageBox.Show("ProcessTenTruePay127还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

          
        }
        private void ProcessFeeSjTruePayInit()
        {
            DataSet ds = m_bllFeeSJTruePayTab.GetListInfo("ShouldRecvMoney = 0");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFeeSJTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeSJTruePayTabID"];
                    DGBY.Model.FeeSJTruePayTab modelFeeSJTruePayTab
                       = m_bllFeeSJTruePayTab.GetModel(nFeeSJTruePayTabID);
                    modelFeeSJTruePayTab.ShouldRecvMoney = -1;
                    m_bllFeeSJTruePayTab.Update(modelFeeSJTruePayTab);
                }
            }
        }

        private void ProcessFeeDZTruePayFac()
        {
            DataSet ds = m_bllFeeDZTruePayTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFeeDZTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeDZTruePayTabID"];
                    int nPaidanRegisterTabID = (int)ds.Tables[0].Rows[i]["PaidanRegisterTabID"];
                    DataSet ds2 = m_bllPaidanRegisterTab.GetListInfo("PaidanRegisterTabID = '" + nPaidanRegisterTabID + "'");

                    DGBY.Model.FeeDZTruePayTab modelFeeDZTruePayTab
                       = m_bllFeeDZTruePayTab.GetModel(nFeeDZTruePayTabID);

                    modelFeeDZTruePayTab.FactoryDataTabID = (int)ds2.Tables[0].Rows[0]["FactoryDataTabID"];
                    //modelFeeSJTruePayTab.BYCompanyTabID = (int)ds2.Tables[0].Rows[0]["BYCompanyTabID"];
                    //modelFeeSJTruePayTab.BYDepartTabID = (int)ds2.Tables[0].Rows[0]["BYDepartTabID"];
                    //modelFeeSJTruePayTab.ShouldRecvMoney = -1;
                    m_bllFeeDZTruePayTab.Update(modelFeeDZTruePayTab);
                }
            }

            MessageBox.Show("ProcessFeeDZTruePayFac还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        private void ProcessFeeHKCWTruePayFac()
        {
            DataSet ds = m_bllFeeHKCWTruePayTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFeeHKCWTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeHKCWTruePayTabID"];
                    int nPaidanRegisterTabID = (int)ds.Tables[0].Rows[i]["PaidanRegisterTabID"];
                    DataSet ds2 = m_bllPaidanRegisterTab.GetListInfo("PaidanRegisterTabID = '" + nPaidanRegisterTabID + "'");

                    DGBY.Model.FeeHKCWTruePayTab modelFeeHKCWTruePayTab
                       = m_bllFeeHKCWTruePayTab.GetModel(nFeeHKCWTruePayTabID);

                    modelFeeHKCWTruePayTab.FactoryDataTabID = (int)ds2.Tables[0].Rows[0]["FactoryDataTabID"];
                    //modelFeeSJTruePayTab.BYCompanyTabID = (int)ds2.Tables[0].Rows[0]["BYCompanyTabID"];
                    //modelFeeSJTruePayTab.BYDepartTabID = (int)ds2.Tables[0].Rows[0]["BYDepartTabID"];
                    //modelFeeSJTruePayTab.ShouldRecvMoney = -1;
                    m_bllFeeHKCWTruePayTab.Update(modelFeeHKCWTruePayTab);
                }
            }

            MessageBox.Show("ProcessFeeHKCWTruePayFac还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        private void ProcessFeeDLCWTruePayFac()
        {
            DataSet ds = m_bllFeeDLCWTruePayTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFeeDLCWTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeDLCWTruePayTabID"];
                    int nPaidanRegisterTabID = (int)ds.Tables[0].Rows[i]["PaidanRegisterTabID"];
                    DataSet ds2 = m_bllPaidanRegisterTab.GetListInfo("PaidanRegisterTabID = '" + nPaidanRegisterTabID + "'");

                    DGBY.Model.FeeDLCWTruePayTab modelFeeDLCWTruePayTab
                       = m_bllFeeDLCWTruePayTab.GetModel(nFeeDLCWTruePayTabID);

                    modelFeeDLCWTruePayTab.FactoryDataTabID = (int)ds2.Tables[0].Rows[0]["FactoryDataTabID"];
                    //modelFeeSJTruePayTab.BYCompanyTabID = (int)ds2.Tables[0].Rows[0]["BYCompanyTabID"];
                    //modelFeeSJTruePayTab.BYDepartTabID = (int)ds2.Tables[0].Rows[0]["BYDepartTabID"];
                    //modelFeeSJTruePayTab.ShouldRecvMoney = -1;
                    m_bllFeeDLCWTruePayTab.Update(modelFeeDLCWTruePayTab);
                }
            }

            MessageBox.Show("ProcessFeeDLCWTruePayFac还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        private void ProcessFeeDHLTruePayFac()
        {
            DataSet ds = m_bllFeeDHLTruePayTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFeeDHLTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeDHLTruePayTabID"];
                    int nPaidanRegisterTabID = (int)ds.Tables[0].Rows[i]["PaidanRegisterTabID"];
                    DataSet ds2 = m_bllPaidanRegisterTab.GetListInfo("PaidanRegisterTabID = '" + nPaidanRegisterTabID + "'");

                    DGBY.Model.FeeDHLTruePayTab modelFeeDHLTruePayTab
                       = m_bllFeeDHLTruePayTab.GetModel(nFeeDHLTruePayTabID);

                    modelFeeDHLTruePayTab.FactoryDataTabID = (int)ds2.Tables[0].Rows[0]["FactoryDataTabID"];
                    //modelFeeSJTruePayTab.BYCompanyTabID = (int)ds2.Tables[0].Rows[0]["BYCompanyTabID"];
                    //modelFeeSJTruePayTab.BYDepartTabID = (int)ds2.Tables[0].Rows[0]["BYDepartTabID"];
                    //modelFeeSJTruePayTab.ShouldRecvMoney = -1;
                    m_bllFeeDHLTruePayTab.Update(modelFeeDHLTruePayTab);
                }
            }

            MessageBox.Show("ProcessFeeDHLTruePayFac还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }

        private void ProcessFeeSjTruePayFacDepComp()
        {
            DataSet ds = m_bllFeeSJTruePayTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFeeSJTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeSJTruePayTabID"];
                    int nPaidanRegisterTabID = (int)ds.Tables[0].Rows[i]["PaidanRegisterTabID"];
                    DataSet ds2 = m_bllPaidanRegisterTab.GetListInfo("PaidanRegisterTabID = '" + nPaidanRegisterTabID + "'");

                    DGBY.Model.FeeSJTruePayTab modelFeeSJTruePayTab
                       = m_bllFeeSJTruePayTab.GetModel(nFeeSJTruePayTabID);

                    modelFeeSJTruePayTab.FactoryDataTabID = (int)ds2.Tables[0].Rows[0]["FactoryDataTabID"];
                    modelFeeSJTruePayTab.BYCompanyTabID = (int)ds2.Tables[0].Rows[0]["BYCompanyTabID"];
                    modelFeeSJTruePayTab.BYDepartTabID = (int)ds2.Tables[0].Rows[0]["BYDepartTabID"];
                    modelFeeSJTruePayTab.ShouldRecvMoney = -1;
                    m_bllFeeSJTruePayTab.Update(modelFeeSJTruePayTab);
                }
            }

            MessageBox.Show("ProcessFeeSjTruePayFacDepComp还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        private Int64 MakeRecvMoneyDetailDJNo(DateTime dt)
        {
            string strDate = dt.Year.ToString() + dt.Month.ToString().PadLeft(2, '0') + dt.Day.ToString().PadLeft(2, '0');
            DataSet ds = m_bllFinCheckInvoiceRecordDetailTab_New.GetSJPackDJNoByDate("DanJuDate = '" + strDate + "'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                string strDJNo = ds.Tables[0].Rows[0]["MaxJPackDJNum"].ToString();
                long nDJNo = 0;
                if (strDJNo != "")
                    nDJNo = Convert.ToInt64(strDJNo, 10);
                nDJNo++;
                string strTemp = "";
                if (strDJNo != "")
                    strTemp = string.Format("{0:d4}", nDJNo);
                else
                    strTemp = strDate + string.Format("{0:d4}", nDJNo);

                return Convert.ToInt64(strTemp, 10);
            }

            return 0;
        }
        private void HuiFuFinCheckInvoiceRecordDetailTab_New()
        {
            DataSet ds = m_bllPaidanRegisterTab.GetFinCheckInvoiceRecordDetailTab_New("PaidanRegisterTab.PaidanRegisterTabID != 127");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DateTime dt = (DateTime)ds.Tables[0].Rows[i]["PaiDanDate"];
                    int nPaidanRegisterTabID = (int)ds.Tables[0].Rows[i]["PaidanRegisterTabID"];

                    DGBY.Model.FinCheckInvoiceRecordDetailTab_New modelFinCheckInvoiceRecordDetailTab_New = new DGBY.Model.FinCheckInvoiceRecordDetailTab_New();
                    modelFinCheckInvoiceRecordDetailTab_New.PaidanRegisterTabID = nPaidanRegisterTabID;
                    modelFinCheckInvoiceRecordDetailTab_New.ShenPiaoDate = DateTime.Parse("1900-01-01");
                    modelFinCheckInvoiceRecordDetailTab_New.DanJuDate = dt;
                    modelFinCheckInvoiceRecordDetailTab_New.TuiPiaoReason = "";
                    modelFinCheckInvoiceRecordDetailTab_New.Note = "";
                    modelFinCheckInvoiceRecordDetailTab_New.USDPercent17 = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.USDPercent16 = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.USDPercent15 = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.USDPercent13 = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.USDPercent9 = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.USDPercent5 = 0;

                    modelFinCheckInvoiceRecordDetailTab_New.HKPercent17 = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.HKPercent16 = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.HKPercent15 = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.HKPercent13 = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.HKPercent9 = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.HKPercent5 = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.HKHuiLv = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.USDHuiLv = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.IsPayTaxDone = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.USDJinE = 0;
                    modelFinCheckInvoiceRecordDetailTab_New.SetPercent = (decimal)0.17;
                    modelFinCheckInvoiceRecordDetailTab_New.TransGongShi = "";
                    modelFinCheckInvoiceRecordDetailTab_New.BianHao = MakeRecvMoneyDetailDJNo(dt).ToString();


                    m_bllFinCheckInvoiceRecordDetailTab_New.Add(modelFinCheckInvoiceRecordDetailTab_New);
                }
            }

            MessageBox.Show("HuiFuFinCheckInvoiceRecordDetailTab_New还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        private void ProcessFinWaihuiIncome()
        {
            DataSet ds = m_bllFinRecvMoneyDetailTab_New.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFinRecvMoneyDetailTab_NewID = (int)ds.Tables[0].Rows[i]["FinRecvMoneyDetailTab_NewID"];

                    DGBY.Model.FinRecvMoneyDetailTab_New modelFinRecvMoneyDetailTab_NewOld = m_bllFinRecvMoneyDetailTab_New.GetModel(nFinRecvMoneyDetailTab_NewID);

                    DataSet ds2 = m_bllFinDepRecvAndPayDetailTab_New.GetList("FinDepRecvAndPayDetailTab_New.RecvBianNo = '" + modelFinRecvMoneyDetailTab_NewOld.BianHao.ToString()
                        + "' and (FinAbstractTabID = 1 or FinAbstractTabID = 5)");
                    if (ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
                    {
                        for (int k = 0; k < ds2.Tables[0].Rows.Count; k++)
                        {
                            int nFinDepRecvAndPayDetailTab_NewID = (int)ds2.Tables[0].Rows[k]["FinDepRecvAndPayDetailTab_NewID"];
                            DGBY.Model.FinDepRecvAndPayDetailTab_New modelFinDepRecvAndPayDetailTab_New = m_bllFinDepRecvAndPayDetailTab_New.GetModel(nFinDepRecvAndPayDetailTab_NewID);
                            Decimal dtFeeTotal = modelFinRecvMoneyDetailTab_NewOld.ShouxuFee
                      + modelFinRecvMoneyDetailTab_NewOld.LiXi
                      + modelFinRecvMoneyDetailTab_NewOld.BaoguanFee
                      + modelFinRecvMoneyDetailTab_NewOld.OtherFee;

                            modelFinDepRecvAndPayDetailTab_New.WaiHuiIncomeGongShi
                                = modelFinRecvMoneyDetailTab_NewOld.YuanBiMoneyValue.ToString()
                                + "-" + dtFeeTotal.ToString() + @"/"
                                + modelFinRecvMoneyDetailTab_NewOld.RMBHuiLv.ToString();

                            if (modelFinRecvMoneyDetailTab_NewOld.RMBHuiLv > 0)
                                modelFinDepRecvAndPayDetailTab_New.WaiHuiIncome
                                    = modelFinRecvMoneyDetailTab_NewOld.YuanBiMoneyValue
                                    - dtFeeTotal / modelFinRecvMoneyDetailTab_NewOld.RMBHuiLv;
                            else
                                modelFinDepRecvAndPayDetailTab_New.WaiHuiIncome = 0;

                            m_bllFinDepRecvAndPayDetailTab_New.Update(modelFinDepRecvAndPayDetailTab_New);
                        }
                    }
                }

                MessageBox.Show("ProcessFinWaihuiIncome完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
        private void ProcessFinRecvMoneyNewComp()
        {
             DataSet ds = m_bllFinRecvMoneyDetailTab_New.GetShouldComp("");
             if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
             {
                 for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                 {
                     int nCompID = (int)ds.Tables[0].Rows[i]["BYCompanyTabID"];
                     int nFinRecvMoneyDetailTab_NewID = (int)ds.Tables[0].Rows[i]["FinRecvMoneyDetailTab_NewID"];
                     DGBY.Model.FinRecvMoneyDetailTab_New modelFinRecvMoneyDetailTab_NewOld = m_bllFinRecvMoneyDetailTab_New.GetModel(nFinRecvMoneyDetailTab_NewID);
                     modelFinRecvMoneyDetailTab_NewOld.BYCompanyTabID = nCompID;
                     m_bllFinRecvMoneyDetailTab_New.Update(modelFinRecvMoneyDetailTab_NewOld);

                 }
                 MessageBox.Show("ProcessFinRecvMoneyNewComp完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
        }
        private void ProcessFinRecvMoneyNewHuiLv()
        {
            DataSet ds = m_bllFinRecvMoneyDetailTab_New.GetList("z1.汇率 != 1");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                 
                    int nFinRecvMoneyDetailTab_NewID = (int)ds.Tables[0].Rows[i]["FinRecvMoneyDetailTab_NewID"];
                    DGBY.Model.FinRecvMoneyDetailTab_New modelFinRecvMoneyDetailTab_NewOld = m_bllFinRecvMoneyDetailTab_New.GetModel(nFinRecvMoneyDetailTab_NewID);
                    modelFinRecvMoneyDetailTab_NewOld.HuiLvGongShi = ds.Tables[0].Rows[i]["汇率公式"].ToString();
                    if (modelFinRecvMoneyDetailTab_NewOld.HuiLvGongShi != "")
                        modelFinRecvMoneyDetailTab_NewOld.HuiLv = this.ultraCalcManager1.Calculate(modelFinRecvMoneyDetailTab_NewOld.HuiLvGongShi).ToDecimal();
                    else
                        modelFinRecvMoneyDetailTab_NewOld.HuiLv = 0;


                    m_bllFinRecvMoneyDetailTab_New.Update(modelFinRecvMoneyDetailTab_NewOld);
                }
            }

            ds = m_bllFinRecvMoneyDetailTab_New.GetList("z1.汇率 != 1 and z1.费用合计USD != 0");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {

                    int nFinRecvMoneyDetailTab_NewID = (int)ds.Tables[0].Rows[i]["FinRecvMoneyDetailTab_NewID"];
                    Decimal dtNewUsd = (Decimal)ds.Tables[0].Rows[i]["扣费后折算为USD"];

                    DataSet ds2 = m_bllFinRecvMoneyAuxiliaryTab_New.GetList("FinRecvMoneyDetailTab_NewID = '"
                        + nFinRecvMoneyDetailTab_NewID.ToString() + "'");
                    if (ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
                    {
                        int nID = Convert.ToInt32(ds2.Tables[0].Rows[0]["FinRecvMoneyAuxiliaryTab_NewID"].ToString(), 10);
                        DGBY.Model.FinRecvMoneyAuxiliaryTab_New modelFinRecvMoneyAuxiliaryTab_New = m_bllFinRecvMoneyAuxiliaryTab_New.GetModel(nID);

                        modelFinRecvMoneyAuxiliaryTab_New.PayTaxMoneyValue = dtNewUsd;

                        m_bllFinRecvMoneyAuxiliaryTab_New.Update(modelFinRecvMoneyAuxiliaryTab_New);
                    }

                }
            }
            MessageBox.Show("ProcessFinRecvMoneyNewHuiLv完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void ReComputeFinRecvMoneyNewHuiLvAuxiliaryForSpecFac()
        {
            //DataSet dsFac = m_bllFinRecvMoneyDetailTab_New.GetFacInfoList("FinRecvMoneyDetailTab_Newid = '" + modelFinRecvMoneyDetailTab_New.FinRecvMoneyDetailTab_NewID + "'");
            //bool bIsHkFac = (bool)dsFac.Tables[0].Rows[0]["是否港币出货工厂"];

            DataSet ds = m_bllFinRecvMoneyDetailTab_New.GetListProcessRecvMoneySync("z1.是否港币出货工厂 > 0");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {

                    int nFinRecvMoneyDetailTab_NewID = (int)ds.Tables[0].Rows[i]["FinRecvMoneyDetailTab_NewID"];
                    Decimal dtNewHKD = (Decimal)ds.Tables[0].Rows[i]["扣费后折算为HKD"];

                    DataSet ds2 = m_bllFinRecvMoneyAuxiliaryTab_New.GetList("FinRecvMoneyDetailTab_NewID = '"
                        + nFinRecvMoneyDetailTab_NewID.ToString() + "'");
                    if (ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
                    {
                        int nID = Convert.ToInt32(ds2.Tables[0].Rows[0]["FinRecvMoneyAuxiliaryTab_NewID"].ToString(), 10);
                        DGBY.Model.FinRecvMoneyAuxiliaryTab_New modelFinRecvMoneyAuxiliaryTab_New = m_bllFinRecvMoneyAuxiliaryTab_New.GetModel(nID);

                        modelFinRecvMoneyAuxiliaryTab_New.PayTaxMoneyValue = dtNewHKD;

                        m_bllFinRecvMoneyAuxiliaryTab_New.Update(modelFinRecvMoneyAuxiliaryTab_New);
                    }

                }
            }
            MessageBox.Show("ReComputeFinRecvMoneyNewHuiLvAuxiliaryForSpecFac完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void ProcessFinRecvMoneyNewHuiLvAuxiliary()
        {


            DataSet ds = m_bllFinRecvMoneyDetailTab_New.GetList("z1.汇率 != 1");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {

                    int nFinRecvMoneyDetailTab_NewID = (int)ds.Tables[0].Rows[i]["FinRecvMoneyDetailTab_NewID"];
                    Decimal dtNewUsd = (Decimal)ds.Tables[0].Rows[i]["扣费后折算为USD"];

                    DataSet ds2 = m_bllFinRecvMoneyAuxiliaryTab_New.GetList("FinRecvMoneyDetailTab_NewID = '"
                        + nFinRecvMoneyDetailTab_NewID.ToString() + "'");
                    if (ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
                    {
                        int nID = Convert.ToInt32(ds2.Tables[0].Rows[0]["FinRecvMoneyAuxiliaryTab_NewID"].ToString(), 10);
                        DGBY.Model.FinRecvMoneyAuxiliaryTab_New modelFinRecvMoneyAuxiliaryTab_New = m_bllFinRecvMoneyAuxiliaryTab_New.GetModel(nID);

                        modelFinRecvMoneyAuxiliaryTab_New.PayTaxMoneyValue = dtNewUsd;

                        m_bllFinRecvMoneyAuxiliaryTab_New.Update(modelFinRecvMoneyAuxiliaryTab_New);
                    }

                }
            }
            MessageBox.Show("ProcessFinRecvMoneyNewHuiLvAuxiliary完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void ProcessFeeDZTruePayMoney()
        {
            DataSet ds = m_bllFeeDZTruePayTab.GetList("DZCounts != 0");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFeeDZTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeDZTruePayTabID"];
                    

                    DGBY.Model.FeeDZTruePayTab modelFeeDZTruePayTab
                       = m_bllFeeDZTruePayTab.GetModel(nFeeDZTruePayTabID);

                    modelFeeDZTruePayTab.decimalFiledReserv1 = (Decimal)ds.Tables[0].Rows[i]["应付实付金额合计公式"];
                    modelFeeDZTruePayTab.decimalFiledReserv2 = (Decimal)ds.Tables[0].Rows[i]["应收金额合计公式"];

                    m_bllFeeDZTruePayTab.Update(modelFeeDZTruePayTab);
                }
            }

            MessageBox.Show("ProcessFeeDZTruePayMoney还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        
        private void ProcessFeeSJTruePayMoney2()
        {
            DataSet ds = m_bllFeeSJTruePayTab.GetList("ShouldRecvMoney = -1");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFeeSJTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeSJTruePayTabID"];


                    DGBY.Model.FeeSJTruePayTab modelFeeSJTruePayTab
                       = m_bllFeeSJTruePayTab.GetModel(nFeeSJTruePayTabID);

                    modelFeeSJTruePayTab.ShouldRecvMoney = 0;
                    //modelFeeDZTruePayTab.decimalFiledReserv2 = (Decimal)ds.Tables[0].Rows[i]["应收金额合计公式"];

                    m_bllFeeSJTruePayTab.Update(modelFeeSJTruePayTab);
                }
            }

            MessageBox.Show("ProcessFeeSJTruePayMoney还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        private void ProcessFeeSJTruePayMoney()
        {
            DataSet ds = m_bllFeeSJTruePayTab.GetList("(case when ShouldRecvNotRecvMoney > 0 then (coalesce(SJ_SJFeeTab.SJFeePriceEachGui,0) * SJCKHTTab.SJGuiCount + coalesce(SJ_SJFeeTab.SJFeeFactor,0) * ShouldRecvNotRecvMoney + coalesce(SJ_SJFeeTab.SJFeeAddValue,0)) else 0 end) != 0");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFeeSJTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeSJTruePayTabID"];


                    DGBY.Model.FeeSJTruePayTab modelFeeSJTruePayTab
                       = m_bllFeeSJTruePayTab.GetModel(nFeeSJTruePayTabID);

                    modelFeeSJTruePayTab.ShouldRecvMoney = (Decimal)ds.Tables[0].Rows[i]["应收金额公式"];
                    //modelFeeDZTruePayTab.decimalFiledReserv2 = (Decimal)ds.Tables[0].Rows[i]["应收金额合计公式"];

                    m_bllFeeSJTruePayTab.Update(modelFeeSJTruePayTab);
                }
            }

            MessageBox.Show("ProcessFeeSJTruePayMoney还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        private void ProcessBYCompBankCountTab()
        {

            try
            {
           
                DGBY.Model.BYCompBankCountTab modelBYCompBankCountTab = new DGBY.Model.BYCompBankCountTab();
                modelBYCompBankCountTab.BYCompanyTabID = 3;
                modelBYCompBankCountTab.CountName = "熊玉均";
                modelBYCompBankCountTab.KHBank = "中国农业银行东莞望牛墩支行";
                modelBYCompBankCountTab.CountNo = "6228480604080830119";

                m_bllBYCompBankCountTab.Add(modelBYCompBankCountTab);

             
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

            try
            {


                DGBY.Model.BYCompBankCountTab modelBYCompBankCountTab = m_bllBYCompBankCountTab.GetModel(1);
                modelBYCompBankCountTab.BYCompanyTabID = 1;
                modelBYCompBankCountTab.CountName = "东莞百业运输公司";
                modelBYCompBankCountTab.KHBank = "农行南城支行";
                modelBYCompBankCountTab.CountNo = "275001040001113";
               

                m_bllBYCompBankCountTab.Update(modelBYCompBankCountTab);


            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }


            MessageBox.Show("BYCompBankCountTab还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        private void DeleteBackTaxRecord(int nSelectFinRecvMoneyDetailTab_NewID)
        {
            m_SQLStringList.Clear();
            m_arrayList.Clear();

            DGBY.Model.FinDepRecvAndPayDetailTab_New modelFinDepRecvAndPayDetailTab_New = m_bllFinDepRecvAndPayDetailTab_New.GetModel(nSelectFinRecvMoneyDetailTab_NewID);


            if ((modelFinDepRecvAndPayDetailTab_New.FinAbstractTabID == 2
                || modelFinDepRecvAndPayDetailTab_New.FinAbstractTabID == 4)
                && modelFinDepRecvAndPayDetailTab_New.PayTaxBenJin > 0)
            {

                string strPayNo = modelFinDepRecvAndPayDetailTab_New.FinDepRecvAndPayDetailTab_NewBianNo;
                DataSet ds = m_bllFinRecvMoneyAuxiliaryTab_New.GetList("PayTaxBianHao = '" + strPayNo + "'");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    int nAppendNumIndex = 0;
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int nFinRecvMoneyAuxiliaryTab_NewID = Convert.ToInt32(ds.Tables[0].Rows[i]["FinRecvMoneyAuxiliaryTab_NewID"].ToString(), 10);
                        int nFinRecvMoneyDetailTab_NewID = Convert.ToInt32(ds.Tables[0].Rows[i]["FinRecvMoneyDetailTab_NewID"].ToString(), 10);


                        DGBY.Model.FinRecvMoneyAuxiliaryTab_New modelFinRecvMoneyAuxiliaryTab_New
                            = m_bllFinRecvMoneyAuxiliaryTab_New.GetModel(nFinRecvMoneyAuxiliaryTab_NewID);
                        if (modelFinRecvMoneyAuxiliaryTab_New.IsPayTaxDone > 0)
                        {
                            modelFinRecvMoneyAuxiliaryTab_New.IsPayTaxDone = 0;
                            modelFinRecvMoneyAuxiliaryTab_New.PayedTaxMoneyValue = 0;
                            modelFinRecvMoneyAuxiliaryTab_New.PayTaxBianHao = "";
                            m_bllFinRecvMoneyAuxiliaryTab_New.TransUpdate(modelFinRecvMoneyAuxiliaryTab_New
                               , m_SQLStringList, m_arrayList, i);


                            if (modelFinRecvMoneyAuxiliaryTab_New.SubSeqNo == 0)
                            {
                                DGBY.Model.FinRecvMoneyDetailTab_New modelFinRecvMoneyDetailTab_New
= m_bllFinRecvMoneyDetailTab_New.GetModel(nFinRecvMoneyDetailTab_NewID);
                                modelFinRecvMoneyDetailTab_New.IsPayTaxDone = 0;
                                m_bllFinRecvMoneyDetailTab_New.TransUpdate(modelFinRecvMoneyDetailTab_New
                                    , m_SQLStringList, m_arrayList, i);

                            }

                            List<int> lstDelRecvAuxiliary = new List<int>();
                            lstDelRecvAuxiliary.Add(nFinRecvMoneyAuxiliaryTab_NewID);
                            DataSet dsTempRecv = m_bllFinRecvMoneyAuxiliaryTab_New.GetList("FinRecvMoneyDetailTab_NewID = '"
                                + nFinRecvMoneyDetailTab_NewID.ToString() + "'");
                            if (dsTempRecv.Tables.Count > 0 && dsTempRecv.Tables[0].Rows.Count > 0)
                            {
                                bool bFatherHadBackTax = false;//子序号为0的节点已经退税
                                for (int k = 0; k < dsTempRecv.Tables[0].Rows.Count; k++)
                                {
                                    nAppendNumIndex++;
                                    int nSubFinRecvMoneyAuxiliaryTab_NewID =
                                        Convert.ToInt32(dsTempRecv.Tables[0].Rows[k]["FinRecvMoneyAuxiliaryTab_NewID"].ToString(), 10);
                                    DGBY.Model.FinRecvMoneyAuxiliaryTab_New modelFinRecvMoneyAuxiliaryTab_New2
= m_bllFinRecvMoneyAuxiliaryTab_New.GetModel(nSubFinRecvMoneyAuxiliaryTab_NewID);

                                    //k==0的情况，当父节点已经退了税（IsPayTaxDone == 0）
                                    //lstDelFatherAuxiliary.Contains(nSubFinCheckInvoiceRecordDetailAuxiliaryTab_NewID)的情况，
                                    //
                                    if (k == 0
                                        //|| lstDelFatherAuxiliary.Contains(nSubFinCheckInvoiceRecordDetailAuxiliaryTab_NewID)
                                        )
                                    {
                                        if (modelFinRecvMoneyAuxiliaryTab_New2.IsPayTaxDone == 0)
                                            bFatherHadBackTax = true;
                                    }
                                    //如果子序号大于0，且已经退税或者（本次要退税且父节点已经退过税）
                                    if (modelFinRecvMoneyAuxiliaryTab_New2.SubSeqNo > 0
                                        && modelFinRecvMoneyAuxiliaryTab_New2.PayedTaxMoneyValue == 0
                                        || (lstDelRecvAuxiliary.Contains(nSubFinRecvMoneyAuxiliaryTab_NewID)
                                        && bFatherHadBackTax)
                                        )
                                    {
                                        m_bllFinRecvMoneyAuxiliaryTab_New.TransDelete(nSubFinRecvMoneyAuxiliaryTab_NewID
                                            , m_SQLStringList, m_arrayList, nAppendNumIndex);
                                    }
                                }
                            }

                        }


                    }
                }

                ds = m_bllInvoiceAuxiliary_New.GetList("PayTaxBianHao = '" + strPayNo + "'");
                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    int nAppendNumIndex = 0;
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        int nFinCheckInvoiceRecordDetailAuxiliaryTab_NewID = Convert.ToInt32(ds.Tables[0].Rows[i]["FinCheckInvoiceRecordDetailAuxiliaryTab_NewID"].ToString(), 10);
                        int nFinCheckInvoiceRecordDetailTab_NewID = Convert.ToInt32(ds.Tables[0].Rows[i]["FinCheckInvoiceRecordDetailTab_NewID"].ToString(), 10);
                        DGBY.Model.FinCheckInvoiceRecordDetailAuxiliaryTab_New modelFinCheckInvoiceRecordDetailAuxiliaryTab_New
                            = m_bllInvoiceAuxiliary_New.GetModel(nFinCheckInvoiceRecordDetailAuxiliaryTab_NewID);
                        //if (modelFinCheckInvoiceRecordDetailAuxiliaryTab_New.SubSeqNo == 0)
                        //    m_bllInvoiceAuxiliary_New.TransDelete(nFinCheckInvoiceRecordDetailAuxiliaryTab_NewID
                        //        , m_SQLStringList, m_arrayList, i);
                        //else 
                        if (modelFinCheckInvoiceRecordDetailAuxiliaryTab_New.IsPayTaxDone > 0)
                        {
                            modelFinCheckInvoiceRecordDetailAuxiliaryTab_New.IsPayTaxDone = 0;
                            modelFinCheckInvoiceRecordDetailAuxiliaryTab_New.PayedTaxMoneyValue = 0;
                            modelFinCheckInvoiceRecordDetailAuxiliaryTab_New.PayTaxBianHao = "";
                            m_bllInvoiceAuxiliary_New.TransUpdate(modelFinCheckInvoiceRecordDetailAuxiliaryTab_New
                                , m_SQLStringList, m_arrayList, i);

                            //本次计划退税（PayedTaxMoneyValue变为0）且子序号为0的补充表的集合。
                            List<int> lstDelFatherAuxiliary = new List<int>();
                            if (modelFinCheckInvoiceRecordDetailAuxiliaryTab_New.SubSeqNo == 0)
                            {
                                DGBY.Model.FinCheckInvoiceRecordDetailTab_New modelFinCheckInvoiceRecordDetailTab_New
= m_bllFinCheckInvoiceRecordDetailTab_New.GetModel(nFinCheckInvoiceRecordDetailTab_NewID);
                                modelFinCheckInvoiceRecordDetailTab_New.IsPayTaxDone = 0;
                                m_bllFinCheckInvoiceRecordDetailTab_New.TransUpdate(modelFinCheckInvoiceRecordDetailTab_New
                                    , m_SQLStringList, m_arrayList, i);

                                lstDelFatherAuxiliary.Add(nFinCheckInvoiceRecordDetailAuxiliaryTab_NewID);

                            }
                            //本次计划退税（PayedTaxMoneyValue变为0）的补充表的集合。
                            List<int> lstDelAuxiliary = new List<int>();
                            lstDelAuxiliary.Add(nFinCheckInvoiceRecordDetailAuxiliaryTab_NewID);
                            DataSet dsTempInvoice = m_bllInvoiceAuxiliary_New.GetList("FinCheckInvoiceRecordDetailTab_NewID = '"
                                + nFinCheckInvoiceRecordDetailTab_NewID.ToString() + "'");
                            if (dsTempInvoice.Tables.Count > 0 && dsTempInvoice.Tables[0].Rows.Count > 0)
                            {
                                bool bFatherHadBackTax = false;//子序号为0的节点已经退税
                                for (int k = 0; k < dsTempInvoice.Tables[0].Rows.Count; k++)
                                {
                                    nAppendNumIndex++;
                                    int nSubFinCheckInvoiceRecordDetailAuxiliaryTab_NewID =
                                        Convert.ToInt32(dsTempInvoice.Tables[0].Rows[k]["FinCheckInvoiceRecordDetailAuxiliaryTab_NewID"].ToString(), 10);
                                    DGBY.Model.FinCheckInvoiceRecordDetailAuxiliaryTab_New modelFinCheckInvoiceRecordDetailAuxiliaryTab_New2
= m_bllInvoiceAuxiliary_New.GetModel(nSubFinCheckInvoiceRecordDetailAuxiliaryTab_NewID);

                                    //k==0的情况，当父节点已经退了税（IsPayTaxDone == 0）
                                    //lstDelFatherAuxiliary.Contains(nSubFinCheckInvoiceRecordDetailAuxiliaryTab_NewID)的情况，
                                    //
                                    if (k == 0
                                        //|| lstDelFatherAuxiliary.Contains(nSubFinCheckInvoiceRecordDetailAuxiliaryTab_NewID)
                                        )
                                    {
                                        if (modelFinCheckInvoiceRecordDetailAuxiliaryTab_New2.IsPayTaxDone == 0)
                                            bFatherHadBackTax = true;
                                    }
                                    //如果子序号大于0，且已经退税或者（本次要退税且父节点已经退过税）
                                    if (modelFinCheckInvoiceRecordDetailAuxiliaryTab_New2.SubSeqNo > 0
                                        && modelFinCheckInvoiceRecordDetailAuxiliaryTab_New2.PayedTaxMoneyValue == 0
                                        || (lstDelAuxiliary.Contains(nSubFinCheckInvoiceRecordDetailAuxiliaryTab_NewID)
                                        && bFatherHadBackTax)
                                        )
                                    {
                                        m_bllInvoiceAuxiliary_New.TransDelete(nSubFinCheckInvoiceRecordDetailAuxiliaryTab_NewID
                                            , m_SQLStringList, m_arrayList, nAppendNumIndex);
                                    }
                                }
                            }

                        }


                        //DataSet dsInvoice = m_bllFinCheckInvoiceRecordDetailTab_New.GetList("FinCheckInvoiceRecordDetailTab_NewID = '" + nFinCheckInvoiceRecordDetailAuxiliaryTab_NewID.ToString() + "'");
                        //if (dsInvoice.Tables.Count > 0 && dsInvoice.Tables[0].Rows.Count > 0)
                        //{
                        //    int nFinCheckInvoiceRecordDetailTab_NewID = Convert.ToInt32(dsInvoice.Tables[0].Rows[0]["FinCheckInvoiceRecordDetailTab_NewID"].ToString(), 10);

                        //}
                    }
                }
                m_bllFinDepRecvAndPayDetailTab_New.TransDelete(nSelectFinRecvMoneyDetailTab_NewID, m_SQLStringList, m_arrayList);
                m_bllSJPackingTab.ExecuteSqlTran(m_SQLStringList, m_arrayList);
                //MessageBox.Show("已退税，不能删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //m_bCanModify = false;
                //return;
            }
        }

        private void ResetBackTaxRecord()
        {
                DataSet ds2 = m_bllFinDepRecvAndPayDetailTab_New.GetList("FinAbstractTabID = 2");

                if (ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
                {
                    for (int k = 0; k < ds2.Tables[0].Rows.Count; k++)
                    {
                        int nFinDepRecvAndPayDetailTab_NewID = (int)ds2.Tables[0].Rows[k]["FinDepRecvAndPayDetailTab_NewID"];
                        DeleteBackTaxRecord(nFinDepRecvAndPayDetailTab_NewID);
                    }
                }


                MessageBox.Show("ResetBackTaxRecord还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void SyncDate(ref DGBY.Model.HxdNoTab modelHxdNoTabOld)
        {
            DataSet dsHxdNoTab = m_bllHxdNoTab.GetDateConfigInfoByBGH("HxdNoTab.HxdNoTabID = '" + modelHxdNoTabOld.HxdNoTabID.ToString() + "'");
            
            if (dsHxdNoTab.Tables.Count > 0 && dsHxdNoTab.Tables[0].Rows.Count > 0)
            {
                if (dsHxdNoTab.Tables[0].Rows[0]["委托书"].ToString() != "")
                {
                    bool bwts = Convert.ToBoolean(dsHxdNoTab.Tables[0].Rows[0]["委托书"].ToString());
                    if (bwts)
                    {
                        modelHxdNoTabOld.QtddjDate = modelHxdNoTabOld.LrHsBgdDate;
                    }
                }

                if (dsHxdNoTab.Tables[0].Rows[0]["六联单"].ToString() != "")
                {
                    bool blld = Convert.ToBoolean(dsHxdNoTab.Tables[0].Rows[0]["六联单"].ToString());
                    if (blld)
                    {
                        modelHxdNoTabOld.HSLLDDate = modelHxdNoTabOld.LrHsBgdDate;
                    }
                }

                if (dsHxdNoTab.Tables[0].Rows[0]["托运单"].ToString() != "")
                {
                    bool btyd = Convert.ToBoolean(dsHxdNoTab.Tables[0].Rows[0]["托运单"].ToString());
                    if (btyd)
                    {
                        modelHxdNoTabOld.HSTYDDate = modelHxdNoTabOld.LrHsBgdDate;
                    }
                }

                if (dsHxdNoTab.Tables[0].Rows[0]["入仓单"].ToString() != "")
                {
                    bool brcd = Convert.ToBoolean(dsHxdNoTab.Tables[0].Rows[0]["入仓单"].ToString());
                    if (brcd)
                    {
                        modelHxdNoTabOld.HSLCDDate = modelHxdNoTabOld.LrHsBgdDate;
                    }
                }

                if (dsHxdNoTab.Tables[0].Rows[0]["放行条"].ToString() != "")
                {
                    bool bfxt = Convert.ToBoolean(dsHxdNoTab.Tables[0].Rows[0]["放行条"].ToString());
                    if (bfxt)
                    {
                        modelHxdNoTabOld.HsbdzldjDate = modelHxdNoTabOld.LrHsBgdDate;
                    }
                }

                if (dsHxdNoTab.Tables[0].Rows[0]["提单"].ToString() != "")
                {
                    bool btd = Convert.ToBoolean(dsHxdNoTab.Tables[0].Rows[0]["提单"].ToString());
                    if (btd)
                    {
                      modelHxdNoTabOld.HstddjDate = modelHxdNoTabOld.LrHsBgdDate;
                    }
                }

                if (dsHxdNoTab.Tables[0].Rows[0]["出口合同"].ToString() != "")
                {
                    bool bckht = Convert.ToBoolean(dsHxdNoTab.Tables[0].Rows[0]["出口合同"].ToString());
                    if (bckht)
                    {
                        modelHxdNoTabOld.SCKHTdjDate = modelHxdNoTabOld.LrHsBgdDate;
                    }
                }
            }
        }
        private void SyncHxdNoDate()
        {
            m_SQLStringList.Clear();
            m_arrayList.Clear();
            //DataSet ds = m_bllHxdNoTab.GetList(@"");
            DataSet ds = m_bllHxdNoTab.ShowZhDjbRec(@"(case when Year(HxdNoTab.SBDate) >= 1900 and HxdNoTab.HxdNo >= 1000000001 then CONVERT(varchar(6), HxdNoTab.TongJDate, 112)
when Year(HxdNoTab.SBDate) = 1900 and HxdNoTab.HxdNo < 1000000001 then CONVERT(varchar(6), HxdNoTab.TongJDate, 112)
when Year(HxdNoTab.SBDate) > 1900 and HxdNoTab.HxdNo < 1000000001 then CONVERT(varchar(6), HxdNoTab.SBDate, 112)
else '' end) = 201208");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nHxdNoTabID = (int)ds.Tables[0].Rows[i]["HxdNoTabID"];
                    DGBY.Model.HxdNoTab modelHxdNoTab
                        = m_bllHxdNoTab.GetModel(nHxdNoTabID);

                    SyncDate(ref modelHxdNoTab);
                    m_bllHxdNoTab.Update(modelHxdNoTab);
                    // m_bllHxdNoTab.TransUpdate(modelHxdNoTab, m_SQLStringList, m_arrayList, i);

                }
                // m_bllSJPackingTab.ExecuteSqlTran(m_SQLStringList, m_arrayList);

                MessageBox.Show("SyncHxdNoDate还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }

        private void ProcessUserPassword()
        {
            DataSet ds = m_bllT_ACL_User.GetAllList();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                int nID = (int)ds.Tables[0].Rows[i]["UserPasswordTabID"];
                string strTemp = ds.Tables[0].Rows[i]["用户名称"].ToString();
                string strCustomField = ds.Tables[0].Rows[i]["CustomField"].ToString();
                if (strTemp == "admin")
                    continue;
                if (strCustomField != "")
                    continue;
                
                DGBY.Model.T_ACL_User modelT_ACL_User
                    = m_bllT_ACL_User.GetModel(nID);


                modelT_ACL_User.Password = EncryptHelper.ComputeHash(modelT_ACL_User.Password, modelT_ACL_User.Name.ToLower());
                modelT_ACL_User.CustomField = "密码已经加密";
                m_bllT_ACL_User.Update(modelT_ACL_User);
                

                //m_bllHxdNoTab.TransUpdate(modelHxdNoTab, m_SQLStringList, m_arrayList, i);

            }
        }

        private void Frm_DataProcess_Load(object sender, EventArgs e)
        {
            ProcessUserPassword();
            //ProcessHxdNoWeiTuoShuDate();
            //ProcessGereralRegHxdNo();

            //ProcessFinInvoiceDate();
            //ProcessFinCheckInvoiceDate();
            //MoidfyTransMethod();
            //return;
            //ProcessHxdNoProblemStep3();
            //ProcessFeeSjTruePay();
            //ProcessGDTYInvoice();
            //ProcessPaidanRegisterTab();
            //ProcessDelContractNo("MPE11-5229");
            //TestDataset2XML();
            //ProcessDisCount();
            //ProcessSJFeeTab();
            //ProcessFacChangeBind();

            //ProcessSpecialContract();
            //ProcessPaidanRegisterDetailTab();
            //ProcessFinInvoiceDate();
            //ProcessPaidanBGTruePay();
             //ProcessTenTruePay127();
            //ProcessFeeSjTruePayInit();
            //ProcessFeeSjTruePayFacDepComp();
            //ProcessFeeDZTruePayFac();
            //ProcessFeeDHLTruePayFac();
            //ProcessFeeDLCWTruePayFac();
            //ProcessFeeHKCWTruePayFac();
            //ProcessPaidanRegisterTab127();
            //HuiFuFinCheckInvoiceRecordDetailTab_New();
            //ProcessFinWaihuiIncome();
            //ProcessFinRecvMoneyNewComp();
            //ProcessFeeDZTruePayMoney();
            //ProcessFeeSJTruePayMoney();
            //ProcessBYCompBankCountTab();
            //ProcessFeeSJTruePayMoney2();
            //ProcessFinRecvMoneyNewHuiLv();
            //ResetBackTaxRecord();
            //ProcessFinRecvMoneyNewHuiLvAuxiliary();
            //ReComputeFinRecvMoneyNewHuiLvAuxiliaryForSpecFac();
            //SyncHxdNoDate();
            //AddHxdNoTab(19098);
            return;
           
            ProcessHxdNoProblemStep1();

            ProcessFinCheckInvoiceRecordDetailTab_New();
            ProcessFinCheckInvoiceRecordDetailTab_New2();
            DelAllFinCheckInvoiceRecordDetailAuxiliaryTab_New();
            DelAllFinRecvMoneyAuxiliaryTab_New();
            DelAllFinRecvMoneyDetailTab_New();
            DelAllFinDepRecvAndPayDetailTab_New();


        }
        private void SetBGMXBackTaxPoint()
        {
            DataSet ds = m_bllBGPackGoodsMXTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nID = Convert.ToInt32(ds.Tables[0].Rows[i]["BGPackGoodsMXTabID"].ToString(), 10);
                    Decimal dtTemp = Convert.ToDecimal(ds.Tables[0].Rows[i]["BackTaxPoint"].ToString());
                    if (dtTemp < 0.1M)
                    {
                        DGBY.Model.BGPackGoodsMXTab modelBGPackGoodsMXTab = m_bllBGPackGoodsMXTab.GetModel(nID);
                        modelBGPackGoodsMXTab.BackTaxPoint = 1.02M;
                        m_bllBGPackGoodsMXTab.Update(modelBGPackGoodsMXTab);
                    }
                }
            }
            MessageBox.Show("退税点还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        private void ProcessGereralRegHxdNo()
        {
            DataSet ds = m_bllHxdNoTab.ShowZhDjbRec("HxdNoTab.HxdNo >= '" + 10000000000001
+ "'" + " and HxdNoTab.HxdNo <= '" + 100000000000001 + "'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nHxdNoTabID = Convert.ToInt32(ds.Tables[0].Rows[i]["HxdNoTabID"].ToString(), 10);
                    string strTemp = ds.Tables[0].Rows[i]["核销单号"].ToString();
                    string strNew = strTemp.Remove(2, 4);
                    DGBY.Model.HxdNoTab modelHxdNoTabOld = m_bllHxdNoTab.GetModel(nHxdNoTabID);
                    modelHxdNoTabOld.HxdNo = Convert.ToInt64(strNew, 10);
                    m_bllHxdNoTab.Update(modelHxdNoTabOld);
                }
                MessageBox.Show("综合登记表核销单号还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }

        private void ProcessGDTYInvoice()
        {
            DataSet ds = m_bllTYInvoiceTab.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nID = Convert.ToInt32(ds.Tables[0].Rows[i]["TYInvoiceTabID"].ToString(), 10);

                    DGBY.Model.TYInvoiceTab modelTYInvoiceTab = m_bllTYInvoiceTab.GetModel(nID);
                    int nYear = modelTYInvoiceTab.PrintDate.Year;
                    if (nYear == 1900)
                        modelTYInvoiceTab.PrintDate = modelTYInvoiceTab.KPDate;
                    //modelTYInvoiceTab.PrintDate = 
                    m_bllTYInvoiceTab.Update(modelTYInvoiceTab);

                }
            }
            MessageBox.Show("广东省发票还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void ProcessDelContractNo(string strContractNo)
        {
            DataSet ds = m_bllPaidanRegisterTab.GetList("ContractCode = '" + strContractNo + "'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                
                 int nID = Convert.ToInt32(ds.Tables[0].Rows[0]["PaidanRegisterTabID"].ToString(), 10);
                 DataSet ds2 = m_bllHxdNoTab.GetList("PaidanRegisterTabID = '" + nID + "'");
                 if (ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
                 {
                     int nHxdNoTabID = Convert.ToInt32(ds2.Tables[0].Rows[0]["HxdNoTabID"].ToString(), 10);
                     m_bllHxdNoTab.Delete(nHxdNoTabID);
                 }
                 m_bllPaidanRegisterTab.Delete(nID);
       
                
            }
            MessageBox.Show("MPE11-5229删除完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void TestDataset2XML()
        {
            DataSet ds = m_bllFactoryDataTab.GetList("");

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                XmlDatasetConvert.ConvertDataSetToXMLFile(ds, "FactoryDataTab.xml");
                DataSet ds2 = XmlDatasetConvert.ConvertXMLFileToDataSet("FactoryDataTab.xml");
                if (ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
                {
                }
                MessageBox.Show("Dataset2XML完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
        private void ProcessSJFeeTab()
        {
            DataSet ds = m_bllFactoryDataTab.GetList("");

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nID = Convert.ToInt32(ds.Tables[0].Rows[i]["FactoryDataTabID"].ToString(), 10);

                    DGBY.Model.SJ_SJFeeTab modelSJ_SJFeeTab = new DGBY.Model.SJ_SJFeeTab();
                    modelSJ_SJFeeTab.FactoryDataTabID = nID;
                    modelSJ_SJFeeTab.SJFeeAddValue = 20;
                    modelSJ_SJFeeTab.SJFeeFactor = 1;
                    modelSJ_SJFeeTab.SJFeePriceEachGui = 200;
                    modelSJ_SJFeeTab.ValidDate = DateTime.Parse("2011-01-01");

                    m_bllSJ_SJFeeTab.Add(modelSJ_SJFeeTab);

                }
                MessageBox.Show("ProcessSJFeeTab完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }

        private void ProcessFacChangeBind()
        {
            DataSet ds = m_bllFacConPeoAndTelTab.GetAllConPList("FactoryDataTab.FactoryNameJX = '名创'");
            int nMingChuangID = 0;
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                nMingChuangID = Convert.ToInt32(ds.Tables[0].Rows[0]["FactoryDataTabID"].ToString(), 10);
            }
            ds = m_bllFacConPeoAndTelTab.GetAllConPList("FactoryDataTab.FactoryNameJX = '创艺'");
            int nChuangyiID = 0;
            int nChuangyiPeoID = 0;
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                nChuangyiID = Convert.ToInt32(ds.Tables[0].Rows[0]["FactoryDataTabID"].ToString(), 10);
                nChuangyiPeoID = Convert.ToInt32(ds.Tables[0].Rows[0]["FacConPeoAndTelTabID"].ToString(), 10);

            }
            ds = m_bllPaidanRegisterTab.GetListEx3("FactoryDataTab.FactoryDataTabID = '" + nMingChuangID.ToString()
                + "' and PaiDanDate > '2011-9-10'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nID = Convert.ToInt32(ds.Tables[0].Rows[i]["PaidanRegisterTabID"].ToString(), 10);

                    DGBY.Model.PaidanRegisterTab modelPaidanRegisterTab = m_bllPaidanRegisterTab.GetModel(nID);
                    modelPaidanRegisterTab.FacConPeoAndTelTabID = nChuangyiPeoID;


                    m_bllPaidanRegisterTab.Update(modelPaidanRegisterTab);

                }
                //MessageBox.Show("ProcessSJFeeTab完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

            ds = m_bllPaidanRegisterTab.GetListEx3("FactoryDataTab.FactoryDataTabID = '" + nMingChuangID.ToString()
                + "' and ContractCode = 'MTE11-1749'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nID = Convert.ToInt32(ds.Tables[0].Rows[i]["PaidanRegisterTabID"].ToString(), 10);

                    DGBY.Model.PaidanRegisterTab modelPaidanRegisterTab = m_bllPaidanRegisterTab.GetModel(nID);
                    modelPaidanRegisterTab.FacConPeoAndTelTabID = nChuangyiPeoID;


                    m_bllPaidanRegisterTab.Update(modelPaidanRegisterTab);

                }
                //MessageBox.Show("ProcessSJFeeTab完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            ds = m_bllPaidanRegisterTab.GetListEx3("FactoryDataTab.FactoryDataTabID = '" + nMingChuangID.ToString()
               + "' and ContractCode = 'MTE11-1748'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nID = Convert.ToInt32(ds.Tables[0].Rows[i]["PaidanRegisterTabID"].ToString(), 10);

                    DGBY.Model.PaidanRegisterTab modelPaidanRegisterTab = m_bllPaidanRegisterTab.GetModel(nID);
                    modelPaidanRegisterTab.FacConPeoAndTelTabID = nChuangyiPeoID;


                    m_bllPaidanRegisterTab.Update(modelPaidanRegisterTab);

                }
                MessageBox.Show("ProcessFacChangeBind完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
       

        private void MoidfyTransMethod()
        {
            m_SQLStringList.Clear();
            m_arrayList.Clear();
            //3->8
            int nYSMethodTabID = 0;
            DataSet dsTemp = m_bllYSMethodTab.GetList("YSMethodName = '公路运输'");
            if (dsTemp.Tables.Count > 0 && dsTemp.Tables[0].Rows.Count > 0)
            {
                nYSMethodTabID = (int)dsTemp.Tables[0].Rows[0]["YSMethodTabID"];
            }
            DataSet ds = m_bllBGCKHTTab.ShowOneOutContractRecFromCK("YSMethodTab.YSMethodName = '汽车运输'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nBGCKHTTabID = (int)ds.Tables[0].Rows[i]["BGCKHTTabID"];
                    DGBY.Model.BGCKHTTab modelBGCKHTTab = m_bllBGCKHTTab.GetModel(nBGCKHTTabID);
                    modelBGCKHTTab.YSMethodTabID = nYSMethodTabID;
                    m_bllBGCKHTTab.TransUpdate(modelBGCKHTTab, m_SQLStringList, m_arrayList, i);
                }

                //MessageBox.Show("报关出口合同运输方法修改完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            ds = m_bllSJCKHTTab.ShowOneOutContractRecEx("YSMethodTab.YSMethodName = '汽车运输'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nSJCKHTTabID = (int)ds.Tables[0].Rows[i]["SJCKHTTabID"];
                    DGBY.Model.SJCKHTTab modelSJCKHTTab = m_bllSJCKHTTab.GetModel(nSJCKHTTabID);
                    modelSJCKHTTab.YSMethodTabID = nYSMethodTabID;
                    m_bllSJCKHTTab.TransUpdate(modelSJCKHTTab, m_SQLStringList, m_arrayList, i);
                }

                //MessageBox.Show("报关出口合同运输方法修改完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            m_bllSJPackingTab.ExecuteSqlTran(m_SQLStringList, m_arrayList);
            MessageBox.Show("出口合同运输方法修改完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }

        private void DelAllFinCheckInvoiceRecordDetailAuxiliaryTab_New()
        {
            DataSet ds = m_bllFinCheckInvoiceRecordDetailAuxiliaryTab_New.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFinCheckInvoiceRecordDetailAuxiliaryTab_NewID = (int)ds.Tables[0].Rows[i]["FinCheckInvoiceRecordDetailAuxiliaryTab_NewID"];
                    m_bllFinCheckInvoiceRecordDetailAuxiliaryTab_New.Delete(nFinCheckInvoiceRecordDetailAuxiliaryTab_NewID);
                    //DGBY.Model.FinCheckInvoiceRecordDetailAuxiliaryTab_New modelFinCheckInvoiceRecordDetailAuxiliaryTab_New
                    //    = m_bllFinCheckInvoiceRecordDetailAuxiliaryTab_New.GetModel(nFinCheckInvoiceRecordDetailAuxiliaryTab_NewID);
                    //modelFinCheckInvoiceRecordDetailAuxiliaryTab_New.PayTaxMoneyValue = 0;
                    //m_bllFinCheckInvoiceRecordDetailAuxiliaryTab_New.Update(modelFinCheckInvoiceRecordDetailAuxiliaryTab_New);
                }

                MessageBox.Show("财务补充审票记录还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }

        private void DelAllFinRecvMoneyAuxiliaryTab_New()
        {
            DataSet ds = m_bllFinRecvMoneyAuxiliaryTab_New.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFinRecvMoneyAuxiliaryTab_NewID = (int)ds.Tables[0].Rows[i]["FinRecvMoneyAuxiliaryTab_NewID"];
                    m_bllFinRecvMoneyAuxiliaryTab_New.Delete(nFinRecvMoneyAuxiliaryTab_NewID);
                    //DGBY.Model.FinCheckInvoiceRecordDetailAuxiliaryTab_New modelFinCheckInvoiceRecordDetailAuxiliaryTab_New
                    //    = m_bllFinCheckInvoiceRecordDetailAuxiliaryTab_New.GetModel(nFinCheckInvoiceRecordDetailAuxiliaryTab_NewID);
                    //modelFinCheckInvoiceRecordDetailAuxiliaryTab_New.PayTaxMoneyValue = 0;
                    //m_bllFinCheckInvoiceRecordDetailAuxiliaryTab_New.Update(modelFinCheckInvoiceRecordDetailAuxiliaryTab_New);
                }

                MessageBox.Show("财务补充收款记录还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }

        private void DelAllFinRecvMoneyDetailTab_New()
        {
            DataSet ds = m_bllFinRecvMoneyDetailTab_New.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFinRecvMoneyDetailTab_NewID = (int)ds.Tables[0].Rows[i]["FinRecvMoneyDetailTab_NewID"];
                    m_bllFinRecvMoneyDetailTab_New.Delete(nFinRecvMoneyDetailTab_NewID);
                }

                MessageBox.Show("财务收款记录还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
        private void DelAllFinDepRecvAndPayDetailTab_New()
        {
            DataSet ds = m_bllFinDepRecvAndPayDetailTab_New.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFinDepRecvAndPayDetailTab_NewID = (int)ds.Tables[0].Rows[i]["FinDepRecvAndPayDetailTab_NewID"];
                    m_bllFinDepRecvAndPayDetailTab_New.Delete(nFinDepRecvAndPayDetailTab_NewID);
                }

                MessageBox.Show("财务付款记录还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
        private void ProcessFinCheckInvoiceRecordDetailTab_New2()
        {
            DataSet ds = m_bllFinCheckInvoiceRecordDetailTab_New.GetFinInvoiceRecordTabInfo(@"IsPayTaxDone > 0");

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFinCheckInvoiceRecordDetailTab_NewID = (int)ds.Tables[0].Rows[i]["FinCheckInvoiceRecordDetailTab_NewID"];
                    DGBY.Model.FinCheckInvoiceRecordDetailTab_New modelFinCheckInvoiceRecordDetailTab_New
                        = m_bllFinCheckInvoiceRecordDetailTab_New.GetModel(nFinCheckInvoiceRecordDetailTab_NewID);

                    modelFinCheckInvoiceRecordDetailTab_New.IsPayTaxDone = 0;
                    m_bllFinCheckInvoiceRecordDetailTab_New.Update(modelFinCheckInvoiceRecordDetailTab_New);
                }

                MessageBox.Show("财务审票记录是否已退税还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
        private void ProcessHxdNoProblemStep3()
        {
            DataSet ds = m_bllHxdNoTabTmp.GetList(@"");

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    string nHxdNo = ds.Tables[0].Rows[i]["HxdNo"].ToString();
                    int nHxdNoTabTmpID = (int)ds.Tables[0].Rows[i]["HxdNoTabTmpID"];
                    DGBY.Model.HxdNoTabTmp modelHxdNoTabTmp
                        = m_bllHxdNoTabTmp.GetModel(nHxdNoTabTmpID);

                    DataSet dsTemp = m_bllHxdNoTab.GetList(@"HxdNo = '" + nHxdNo.ToString() + "'");

                    int nHxdNoTabID = 0;
                    if (dsTemp.Tables.Count > 0 && dsTemp.Tables[0].Rows.Count > 0)
                    {
                        nHxdNoTabID = (int)dsTemp.Tables[0].Rows[0]["HxdNoTabID"];
                    }
                    if (nHxdNoTabID > 0)
                    {
                        //int nHxdNoTabID = (int)ds.Tables[0].Rows[i]["HxdNoTabID"];
                        DGBY.Model.HxdNoTab modelHxdNoTab
                            = m_bllHxdNoTab.GetModel(nHxdNoTabID);

                        //DGBY.Model.HxdNoTabTmp modelHxdNoTabTmp = new DGBY.Model.HxdNoTabTmp();
                        modelHxdNoTab.JCHxdDjTabID = modelHxdNoTabTmp.JCHxdDjTabID;
                        modelHxdNoTab.PaidanRegisterTabID = (int)modelHxdNoTabTmp.PaidanRegisterTabID;
                        modelHxdNoTab.HxdNo = modelHxdNoTabTmp.HxdNo;
                        modelHxdNoTab.BGDNo = modelHxdNoTabTmp.BGDNo;
                        modelHxdNoTab.SBDate = modelHxdNoTabTmp.SBDate;
                        modelHxdNoTab.LrHsBgdDate = modelHxdNoTabTmp.LrHsBgdDate;
                        modelHxdNoTab.SdHxdDate = modelHxdNoTabTmp.SdHxdDate;
                        modelHxdNoTab.YhxDate = modelHxdNoTabTmp.YhxDate;
                        modelHxdNoTab.HZzsInvDate = modelHxdNoTabTmp.HZzsInvDate;
                        modelHxdNoTab.JcGHHTDate = modelHxdNoTabTmp.JcGHHTDate;
                        modelHxdNoTab.HsGHHTDate = modelHxdNoTabTmp.HsGHHTDate;
                        modelHxdNoTab.JcwTszldDate = modelHxdNoTabTmp.JcwTszldDate;
                        modelHxdNoTab.TuiShuiZHDate = modelHxdNoTabTmp.TuiShuiZHDate;
                        modelHxdNoTab.QtddjDate = modelHxdNoTabTmp.QtddjDate;

                        modelHxdNoTab.HstddjDate = modelHxdNoTabTmp.HstddjDate;
                        modelHxdNoTab.SCKHTdjDate = modelHxdNoTabTmp.SCKHTdjDate;
                        modelHxdNoTab.XbdzldjDate = modelHxdNoTabTmp.XbdzldjDate;
                        modelHxdNoTab.HsbdzldjDate = modelHxdNoTabTmp.HsbdzldjDate;
                        modelHxdNoTab.ZlccdjDate = modelHxdNoTabTmp.ZlccdjDate;
                        modelHxdNoTab.HsggzldjDate = modelHxdNoTabTmp.HsggzldjDate;

                        modelHxdNoTab.Note = modelHxdNoTabTmp.Note;
                        modelHxdNoTab.CKouDate = modelHxdNoTabTmp.CKouDate;
                        modelHxdNoTab.TongJDate = modelHxdNoTabTmp.TongJDate;

                        m_bllHxdNoTab.Update(modelHxdNoTab);
                    }
                    else
                    {
                        int a = 0;
                    }
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent17 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent16 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent15 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent13 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent9 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent5 = 0;

                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent17 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent16 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent15 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent13 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent9 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent5 = 0;
                    //// modelFinCheckInvoiceRecordDetailTab_New.IsPayTaxDone = 0;
                    //m_bllFinCheckInvoiceRecordDetailTab_New.Update(modelFinCheckInvoiceRecordDetailTab_New);
                }

                MessageBox.Show("回收资料还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
        //再转不带空白的正确出口日期的到tmp，此时是bak1， 这时就应该转那几个字段，不应该全转
        private void ProcessHxdNoProblemStep2()
        {
            DataSet ds = m_bllHxdNoTabTmp.GetList(@"SCKHTdjDate IS NULL");

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    string nHxdNo = ds.Tables[0].Rows[i]["HxdNo"].ToString();
                    int nHxdNoTabTmpID = (int)ds.Tables[0].Rows[i]["HxdNoTabTmpID"];
                    DGBY.Model.HxdNoTabTmp modelHxdNoTabTmp
                        = m_bllHxdNoTabTmp.GetModel(nHxdNoTabTmpID);

                    DataSet dsTemp = m_bllHxdNoTab.GetList(@"HxdNo = '" + nHxdNo.ToString() + "'");

                    int nHxdNoTabID = 0;
                    if (dsTemp.Tables.Count > 0 && dsTemp.Tables[0].Rows.Count > 0)
                    {
                        nHxdNoTabID = (int)dsTemp.Tables[0].Rows[0]["HxdNoTabID"];
                    }
                    if (nHxdNoTabID > 0)
                    {
                        //int nHxdNoTabID = (int)ds.Tables[0].Rows[i]["HxdNoTabID"];
                        DGBY.Model.HxdNoTab modelHxdNoTab
                            = m_bllHxdNoTab.GetModel(nHxdNoTabID);

                        //DGBY.Model.HxdNoTabTmp modelHxdNoTabTmp = new DGBY.Model.HxdNoTabTmp();
                        //modelHxdNoTabTmp.JCHxdDjTabID = modelHxdNoTab.JCHxdDjTabID;
                        //modelHxdNoTabTmp.PaidanRegisterTabID = (int)modelHxdNoTab.PaidanRegisterTabID;
                        //modelHxdNoTabTmp.HxdNo = modelHxdNoTab.HxdNo;
                        //modelHxdNoTabTmp.BGDNo = modelHxdNoTab.BGDNo;
                        //modelHxdNoTabTmp.SBDate = modelHxdNoTab.SBDate;

                        modelHxdNoTabTmp.SdHxdDate = modelHxdNoTab.SdHxdDate;
                        modelHxdNoTabTmp.YhxDate = modelHxdNoTab.YhxDate;
                        //modelHxdNoTabTmp.HZzsInvDate = modelHxdNoTab.HZzsInvDate;
                        //modelHxdNoTabTmp.JcGHHTDate = modelHxdNoTab.JcGHHTDate;
                        modelHxdNoTabTmp.HsGHHTDate = modelHxdNoTab.HsGHHTDate;
                       // modelHxdNoTabTmp.JcwTszldDate = modelHxdNoTab.JcwTszldDate;
                      //  modelHxdNoTabTmp.TuiShuiZHDate = modelHxdNoTab.TuiShuiZHDate;
                        modelHxdNoTabTmp.QtddjDate = modelHxdNoTab.QtddjDate;

                        modelHxdNoTabTmp.HstddjDate = modelHxdNoTab.HstddjDate;
                        modelHxdNoTabTmp.SCKHTdjDate = modelHxdNoTab.SCKHTdjDate;
                       // modelHxdNoTabTmp.XbdzldjDate = modelHxdNoTab.XbdzldjDate;
                       // modelHxdNoTabTmp.HsbdzldjDate = modelHxdNoTab.HsbdzldjDate;
                       // modelHxdNoTabTmp.ZlccdjDate = modelHxdNoTab.ZlccdjDate;
                      //  modelHxdNoTabTmp.HsggzldjDate = modelHxdNoTab.HsggzldjDate;

                        modelHxdNoTabTmp.Note = modelHxdNoTab.Note;
                       // modelHxdNoTabTmp.CKouDate = modelHxdNoTab.CKouDate;
                      //  modelHxdNoTabTmp.TongJDate = modelHxdNoTab.TongJDate;
                        m_bllHxdNoTabTmp.Update(modelHxdNoTabTmp);
                    }
                    else
                    {
                        int a = 0;
                    }
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent17 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent16 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent15 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent13 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent9 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent5 = 0;

                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent17 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent16 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent15 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent13 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent9 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent5 = 0;
                    //// modelFinCheckInvoiceRecordDetailTab_New.IsPayTaxDone = 0;
                    //m_bllFinCheckInvoiceRecordDetailTab_New.Update(modelFinCheckInvoiceRecordDetailTab_New);
                }

                MessageBox.Show("财务审票记录还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
        private void ProcessHxdNoWeiTuoShuDate()
        {
            m_SQLStringList.Clear();
            m_arrayList.Clear();
            DataSet ds = m_bllHxdNoTab.GetList(@"");

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nHxdNoTabID = (int)ds.Tables[0].Rows[i]["HxdNoTabID"];
                    DGBY.Model.HxdNoTab modelHxdNoTab
                        = m_bllHxdNoTab.GetModel(nHxdNoTabID);

                    modelHxdNoTab.QtddjDate = DateTime.Parse("1900-01-01");
                    m_bllHxdNoTab.Update(modelHxdNoTab);
                   // m_bllHxdNoTab.TransUpdate(modelHxdNoTab, m_SQLStringList, m_arrayList, i);

                }
               // m_bllSJPackingTab.ExecuteSqlTran(m_SQLStringList, m_arrayList);

                MessageBox.Show("委托书日期还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
        //先复制带空白的正确出口日期的到tmp此时是bak2
        private void ProcessHxdNoProblemStep1()
        {
            DataSet ds = m_bllHxdNoTab.GetList(@"SCKHTdjDate IS NULL");

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nHxdNoTabID = (int)ds.Tables[0].Rows[i]["HxdNoTabID"];
                    DGBY.Model.HxdNoTab modelHxdNoTab
                        = m_bllHxdNoTab.GetModel(nHxdNoTabID);

                    DGBY.Model.HxdNoTabTmp modelHxdNoTabTmp = new DGBY.Model.HxdNoTabTmp();
                    modelHxdNoTabTmp.JCHxdDjTabID = modelHxdNoTab.JCHxdDjTabID;
                    modelHxdNoTabTmp.PaidanRegisterTabID = (int)modelHxdNoTab.PaidanRegisterTabID;
                    modelHxdNoTabTmp.HxdNo = modelHxdNoTab.HxdNo;
                    modelHxdNoTabTmp.BGDNo = modelHxdNoTab.BGDNo;
                    modelHxdNoTabTmp.SBDate = modelHxdNoTab.SBDate;
                    modelHxdNoTabTmp.LrHsBgdDate = modelHxdNoTab.LrHsBgdDate;
                    modelHxdNoTabTmp.SdHxdDate = modelHxdNoTab.SdHxdDate;
                    modelHxdNoTabTmp.YhxDate = modelHxdNoTab.YhxDate;
                    modelHxdNoTabTmp.HZzsInvDate = modelHxdNoTab.HZzsInvDate;
                    modelHxdNoTabTmp.JcGHHTDate = modelHxdNoTab.JcGHHTDate;
                    modelHxdNoTabTmp.HsGHHTDate = modelHxdNoTab.HsGHHTDate;
                    modelHxdNoTabTmp.JcwTszldDate = modelHxdNoTab.JcwTszldDate;
                    modelHxdNoTabTmp.TuiShuiZHDate = modelHxdNoTab.TuiShuiZHDate;
                    modelHxdNoTabTmp.QtddjDate = modelHxdNoTab.QtddjDate;

                    modelHxdNoTabTmp.HstddjDate = modelHxdNoTab.HstddjDate;
                    modelHxdNoTabTmp.SCKHTdjDate = modelHxdNoTab.SCKHTdjDate;
                    modelHxdNoTabTmp.XbdzldjDate = modelHxdNoTab.XbdzldjDate;
                    modelHxdNoTabTmp.HsbdzldjDate = modelHxdNoTab.HsbdzldjDate;
                    modelHxdNoTabTmp.ZlccdjDate = modelHxdNoTab.ZlccdjDate;
                    modelHxdNoTabTmp.HsggzldjDate = modelHxdNoTab.HsggzldjDate;

                    modelHxdNoTabTmp.Note = modelHxdNoTab.Note;
                    modelHxdNoTabTmp.CKouDate = modelHxdNoTab.CKouDate;
                    modelHxdNoTabTmp.TongJDate = modelHxdNoTab.TongJDate;
                    m_bllHxdNoTabTmp.Update(modelHxdNoTabTmp);
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent17 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent16 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent15 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent13 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent9 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.USDPercent5 = 0;

                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent17 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent16 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent15 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent13 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent9 = 0;
                    //modelFinCheckInvoiceRecordDetailTab_New.HKPercent5 = 0;
                    //// modelFinCheckInvoiceRecordDetailTab_New.IsPayTaxDone = 0;
                    //m_bllFinCheckInvoiceRecordDetailTab_New.Update(modelFinCheckInvoiceRecordDetailTab_New);
                }

                MessageBox.Show("财务审票记录还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
        private void ProcessDisCount()
        {
            DataSet ds = m_bllBGPackGoodsMXTab.GetList(@"");

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nBGPackGoodsMXTabID = (int)ds.Tables[0].Rows[i]["BGPackGoodsMXTabID"];
                    DGBY.Model.BGPackGoodsMXTab modelBGPackGoodsMXTab
                        = m_bllBGPackGoodsMXTab.GetModel(nBGPackGoodsMXTabID);

                    modelBGPackGoodsMXTab.HMaoWeight = modelBGPackGoodsMXTab.CKHTDCost;
                    modelBGPackGoodsMXTab.HZMaoWeight = modelBGPackGoodsMXTab.CKHTJinE;
                    System.Threading.Thread.Sleep(10);
                    m_bllBGPackGoodsMXTab.Update(modelBGPackGoodsMXTab);
                }
            }
            
            ds = m_bllSJPackGoodsMXTab.GetList(@"");

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nSJPackGoodsMXTabID = (int)ds.Tables[0].Rows[i]["SJPackGoodsMXTabID"];
                    DGBY.Model.SJPackGoodsMXTab modelSJPackGoodsMXTab
                        = m_bllSJPackGoodsMXTab.GetModel(nSJPackGoodsMXTabID);

                    modelSJPackGoodsMXTab.GouHHTDCost = modelSJPackGoodsMXTab.CKHTDCost;
                    modelSJPackGoodsMXTab.GouHHTJinE = modelSJPackGoodsMXTab.CKHTJinE;
                    System.Threading.Thread.Sleep(10);
                    m_bllSJPackGoodsMXTab.Update(modelSJPackGoodsMXTab);
                }
            }
            MessageBox.Show("折扣还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        //先复制带空白的正确出口日期的到tmp此时是bak2
        private void ProcessFeeSjTruePay()
        {
            m_SQLStringList.Clear();
            m_arrayList.Clear();
            DataSet ds = m_bllFeeSJTruePayTab.GetList("");

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nFeeSJTruePayTabID = (int)ds.Tables[0].Rows[i]["FeeSJTruePayTabID"];
                    int nPaidanRegisterTabID = (int)ds.Tables[0].Rows[i]["PaidanRegisterTabID"];
                    DataSet dsTemp = m_bllSJPackingTab.GetList("PaidanRegisterTabID = '" + nPaidanRegisterTabID.ToString() + "'");
                    string strSjDjNo = dsTemp.Tables[0].Rows[0]["SJPackDJNo"].ToString();
                    string strTemp = strSjDjNo.Substring(6, 2);
                    strTemp = "2011-09-" + strTemp;
                    DateTime date = DateTime.Parse(strTemp);
                    DGBY.Model.FeeSJTruePayTab modelFeeSJTruePayTab
                        = m_bllFeeSJTruePayTab.GetModel(nFeeSJTruePayTabID);

                    modelFeeSJTruePayTab.ToPubBianHao = "";
                    modelFeeSJTruePayTab.ToPrivateBianHao = "";

                    modelFeeSJTruePayTab.TruePayDate = null;
                    modelFeeSJTruePayTab.InputDate = null; 
                    modelFeeSJTruePayTab.TruePayMonth = 0;
                    modelFeeSJTruePayTab.ShouldPayMonth = 0;
                    modelFeeSJTruePayTab.ShouldRecvNotRecvMoney = 0;

                    modelFeeSJTruePayTab.ToPubFormula = "";
                    modelFeeSJTruePayTab.ToPrivateFormula = "";

                    modelFeeSJTruePayTab.JinBanPerson = "";
                    modelFeeSJTruePayTab.RecvMonyePerson = "";

                    modelFeeSJTruePayTab.IsToRecvPayTab = 0;
                    modelFeeSJTruePayTab.IsToFinCheckMoneyTab = 0;
                    modelFeeSJTruePayTab.Note = "";
                    modelFeeSJTruePayTab.SjDate = date.Date;

                    m_bllFeeSJTruePayTab.TransUpdate(modelFeeSJTruePayTab, m_SQLStringList, m_arrayList, i);
                  
                }
                m_bllSJPackingTab.ExecuteSqlTran(m_SQLStringList, m_arrayList);
                MessageBox.Show("费用商检实付还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
        private void ProcessFinCheckInvoiceRecordDetailTab_New()
        {
             DataSet ds = m_bllFinCheckInvoiceRecordDetailTab_New.GetFinInvoiceRecordTabInfo(@"
            usdpercent17 + usdpercent16 + usdpercent15 + usdpercent13 + usdpercent9 + usdpercent5
+ hkpercent17 + hkpercent16 + hkpercent15 + hkpercent13 + hkpercent9 + hkpercent5 > 0");

             if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
             {
                 for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                 {
                     int nFinCheckInvoiceRecordDetailTab_NewID = (int)ds.Tables[0].Rows[i]["FinCheckInvoiceRecordDetailTab_NewID"];
                     DGBY.Model.FinCheckInvoiceRecordDetailTab_New modelFinCheckInvoiceRecordDetailTab_New
                         = m_bllFinCheckInvoiceRecordDetailTab_New.GetModel(nFinCheckInvoiceRecordDetailTab_NewID);

                     modelFinCheckInvoiceRecordDetailTab_New.USDPercent17 = 0;
                     modelFinCheckInvoiceRecordDetailTab_New.USDPercent16 = 0;
                     modelFinCheckInvoiceRecordDetailTab_New.USDPercent15 = 0;
                     modelFinCheckInvoiceRecordDetailTab_New.USDPercent13 = 0;
                     modelFinCheckInvoiceRecordDetailTab_New.USDPercent9 = 0;
                     modelFinCheckInvoiceRecordDetailTab_New.USDPercent5 = 0;

                     modelFinCheckInvoiceRecordDetailTab_New.HKPercent17 = 0;
                     modelFinCheckInvoiceRecordDetailTab_New.HKPercent16 = 0;
                     modelFinCheckInvoiceRecordDetailTab_New.HKPercent15 = 0;
                     modelFinCheckInvoiceRecordDetailTab_New.HKPercent13 = 0;
                     modelFinCheckInvoiceRecordDetailTab_New.HKPercent9 = 0;
                     modelFinCheckInvoiceRecordDetailTab_New.HKPercent5 = 0;
                    // modelFinCheckInvoiceRecordDetailTab_New.IsPayTaxDone = 0;
                     m_bllFinCheckInvoiceRecordDetailTab_New.Update(modelFinCheckInvoiceRecordDetailTab_New);
                 }

                 MessageBox.Show("财务审票记录还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

             }
        }
        private void ProcessSpecialContract()
        {
            DataSet dsTemp = m_bllPaidanRegisterTab.GetAllPaiDanList("PaidanRegisterTab.ContractCode = 'DMY11-120'");

            if (dsTemp.Tables.Count > 0 && dsTemp.Tables[0].Rows.Count > 0)
            {
                int nID = Convert.ToInt32(dsTemp.Tables[0].Rows[0]["PaidanRegisterTabID"].ToString(), 10);
                DGBY.Model.PaidanRegisterTab modelPaidanRegisterTab = m_bllPaidanRegisterTab.GetModel(nID);
                modelPaidanRegisterTab.BYDepartTabID = 3;
                m_bllPaidanRegisterTab.Update(modelPaidanRegisterTab);
                MessageBox.Show("ProcessSpecialContract还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
        private void ProcessFinInvoiceDate()
        {
            DataSet ds = m_bllFinInvoiceRecordTab_New.GetList("InvoiceNo = ''");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nID = Convert.ToInt32(ds.Tables[0].Rows[i]["FinInvoiceRecordTab_NewID"].ToString(), 10);
                    //DateTime dtTemp = (DateTime)ds.Tables[0].Rows[i]["KaiPiaoDate"];
                    //DateTime dtTemp2 = (DateTime)ds.Tables[0].Rows[i]["LuDanDate"];
                    DGBY.Model.FinInvoiceRecordTab_New modelFinInvoiceRecordTab_New = m_bllFinInvoiceRecordTab_New.GetModel(nID);
                    modelFinInvoiceRecordTab_New.KaiPiaoDate = null;
                    modelFinInvoiceRecordTab_New.LuDanDate = null;
                    m_bllFinInvoiceRecordTab_New.Update(modelFinInvoiceRecordTab_New);

                }
            }
            MessageBox.Show("开票日期还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        private void AddFinInvoiceRecordTabNewAfterTrans(int nPaidanRegisterTabID)
        {
            DataSet ds = m_bllFinInvoiceRecordTab_New.GetList("FinInvoiceRecordTab_New.PaidanRegisterTabID = '" + nPaidanRegisterTabID + "'");

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                return;
            }
            Decimal dtBackTaxPoint = 0;
            DataSet dsInfo = m_bllFactoryGoodsTab.GetGoodsBandInfo("PaidanRegisterTab.PaidanRegisterTabID = '"
                + nPaidanRegisterTabID.ToString() + "'");
            if (dsInfo.Tables.Count > 0 && dsInfo.Tables[0].Rows.Count > 0)
            {
                dtBackTaxPoint = Convert.ToDecimal(dsInfo.Tables[0].Rows[0]["退税点"].ToString());
            }
            int nFormulaSelector = 0;
            Decimal dtFactorA = 0;
            dsInfo = m_bllFactoryDataTab.GetFactorAInfo("PaidanRegisterTab.PaidanRegisterTabID = '"
                + nPaidanRegisterTabID.ToString() + "'");
            if (dsInfo.Tables.Count > 0 && dsInfo.Tables[0].Rows.Count > 0)
            {
                dtFactorA = Convert.ToDecimal(dsInfo.Tables[0].Rows[0]["系数A"].ToString());
                nFormulaSelector = Convert.ToInt32(dsInfo.Tables[0].Rows[0]["公式选择"].ToString(), 10);

            }
            //int nBGDComeBackTabID = 0;
            //ds = m_bllBGDComeBackTab.GetList("PaidanRegisterTabID = '" + nPaidanRegisterTabID.ToString() + "'");
            //if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            //{
            //    nBGDComeBackTabID = Convert.ToInt32(ds.Tables[0].Rows[0]["BGDComeBackTabID"].ToString(), 10);
            //}
            //进出口统一发票
            DGBY.Model.FinInvoiceRecordTab_New modelFinInvoiceRecordTab_New = new DGBY.Model.FinInvoiceRecordTab_New();
            modelFinInvoiceRecordTab_New.PaidanRegisterTabID = nPaidanRegisterTabID;
            modelFinInvoiceRecordTab_New.KaiPiaoHuiLv = 0;
            modelFinInvoiceRecordTab_New.KaiPiaoDate = System.DateTime.Now.Date;
            modelFinInvoiceRecordTab_New.InvoiceNo = "";
            modelFinInvoiceRecordTab_New.JinE = 0;
            modelFinInvoiceRecordTab_New.ShuiJin = 0;
            modelFinInvoiceRecordTab_New.ChuKouYearMonth = "";
            modelFinInvoiceRecordTab_New.LuDanDate = System.DateTime.Now.Date;
            modelFinInvoiceRecordTab_New.BackTaxPoint = dtBackTaxPoint;
            modelFinInvoiceRecordTab_New.FactorA = dtFactorA;
            modelFinInvoiceRecordTab_New.FactorB = 1.17M;
            modelFinInvoiceRecordTab_New.PriceTaxFormulaSelector = nFormulaSelector;
            modelFinInvoiceRecordTab_New.JinECheckIgnore = 0;
            modelFinInvoiceRecordTab_New.IsGouHouContractPrint = "否";
            modelFinInvoiceRecordTab_New.IsKaiPiaoFinish = 0;

            m_bllFinInvoiceRecordTab_New.Add(modelFinInvoiceRecordTab_New);
        }
        //private DGBY.BLL.PaidanRegisterTab m_bllPaidanRegisterTab = new DGBY.BLL.PaidanRegisterTab();
        private void ProcessPaidanRegisterTab()
        {
            DataSet ds = m_bllPaidanRegisterTab.GetList("PaiDanDate > '20111014'");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nID = Convert.ToInt32(ds.Tables[0].Rows[i]["PaidanRegisterTabID"].ToString(), 10);
                    DataSet ds2 = m_bllBGPackingTab.GetList("PaidanRegisterTabID = '" + nID + "'");
                    if (ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
                    {
                        AddFinInvoiceRecordTabNewAfterTrans(nID);
                    }
                    else
                    {
                        continue;
                    }
                    //DGBY.Model.FinCheckInvoiceRecordDetailTab_New modelFinCheckInvoiceRecordDetailTab_New = m_bllFinCheckInvoiceRecordDetailTab_New.GetModel(nID);
                    //modelFinCheckInvoiceRecordDetailTab_New.ShenPiaoDate = dtTemp.Date;
                    //modelFinCheckInvoiceRecordDetailTab_New.DanJuDate = dtTemp2.Date;
                    //m_bllFinCheckInvoiceRecordDetailTab_New.Update(modelFinCheckInvoiceRecordDetailTab_New);

                }
            }
            MessageBox.Show("开票日期还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
        private void ProcessFinCheckInvoiceDate()
        {
            DataSet ds = m_bllFinCheckInvoiceRecordDetailTab_New.GetList("");
            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    int nID = Convert.ToInt32(ds.Tables[0].Rows[i]["FinCheckInvoiceRecordDetailTab_NewID"].ToString(), 10);
                    DateTime dtTemp = (DateTime)ds.Tables[0].Rows[i]["ShenPiaoDate"];
                    DateTime dtTemp2 = new DateTime();
                    if (ds.Tables[0].Rows[i]["DanJuDate"].ToString() != "")
                        dtTemp2 = (DateTime)ds.Tables[0].Rows[i]["DanJuDate"];
                    else
                        dtTemp2 = System.DateTime.Now.Date;
                    DGBY.Model.FinCheckInvoiceRecordDetailTab_New modelFinCheckInvoiceRecordDetailTab_New = m_bllFinCheckInvoiceRecordDetailTab_New.GetModel(nID);
                    modelFinCheckInvoiceRecordDetailTab_New.ShenPiaoDate = dtTemp.Date;
                    modelFinCheckInvoiceRecordDetailTab_New.DanJuDate = dtTemp2.Date;
                    m_bllFinCheckInvoiceRecordDetailTab_New.Update(modelFinCheckInvoiceRecordDetailTab_New);

                }
            }
            MessageBox.Show("开票日期还原完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }

        private void ProcessPaidanRegisterTab127()
        {
// m_bllBGPackingTab = new DG
//XTab m_bllBGPackGoodsMXTab 

           DataSet dsInfo = m_bllBGPackingTab.GetList("PaidanRegisterTabID = 127");

           if (dsInfo.Tables.Count > 0 && dsInfo.Tables[0].Rows.Count > 0)
           {
               for (int i = 0; i < dsInfo.Tables[0].Rows.Count; i++)
               {
                   int nBGPackingTabID = (int)dsInfo.Tables[0].Rows[i]["BGPackingTabID"];
                   m_bllBGPackingTab.Delete(nBGPackingTabID);
               }
           }
           dsInfo = m_bllSJPackingTab.GetList("PaidanRegisterTabID = 127");

           if (dsInfo.Tables.Count > 0 && dsInfo.Tables[0].Rows.Count > 0)
           {
               for (int i = 0; i < dsInfo.Tables[0].Rows.Count; i++)
               {
                   int nSJPackingTabID = (int)dsInfo.Tables[0].Rows[i]["SJPackingTabID"];
                   m_bllSJPackingTab.Delete(nSJPackingTabID);
               }
           }
            MessageBox.Show("ProcessPaidanRegisterTab127完成！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
    }
}
